⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
import { and, eq } from "drizzle-orm";
import { HTTPException } from "hono/http-exception";
import db from "../../database";
import { activityTable, taskTable } from "../../database/schema";
import { publishEvent } from "../../events";
import { deleteOrphanedAssets } from "../../storage/cleanup-assets";
async function updateComment(userId: string, id: string, content: string) {
const [existing] = await db
.select({
id: activityTable.id,
content: activityTable.content,
taskId: activityTable.taskId,
})
.from(activityTable)
.where(
and(
eq(activityTable.id, id),
eq(activityTable.userId, userId),
eq(activityTable.type, "comment"),
),
)
.limit(1);
if (!existing) {
throw new HTTPException(404, {
message: "Comment not found or you are not the author",
});
}
const [updated] = await db
.update(activityTable)
.set({ content })
.where(
and(
eq(activityTable.id, id),
eq(activityTable.userId, userId),
eq(activityTable.type, "comment"),
),
)
.returning();
if (!updated) {
throw new HTTPException(404, {
message: "Comment not found or you are not the author",
});
}
const [task] = await db
.select({ projectId: taskTable.projectId })
.from(taskTable)
.where(eq(taskTable.id, updated.taskId))
.limit(1);
if (task) {
await publishEvent("comment.updated", {
...updated,
projectId: task.projectId,
userId,
});
}
deleteOrphanedAssets(existing.content, content, {
taskId: existing.taskId,
}).catch(() => {});
return updated;
}
export default updateComment;