⚡ 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
feat(tasks): notify members @mentioned in a task description (#1353)
Andrej554b5ac9e4f2
diff --git a/apps/api/src/task/controllers/update-task-description.ts b/apps/api/src/task/controllers/update-task-description.tsindex 1efe82680..6a232a9de 100644--- a/apps/api/src/task/controllers/update-task-description.ts+++ b/apps/api/src/task/controllers/update-task-description.ts@@ -1,9 +1,11 @@import { eq } from "drizzle-orm";import { HTTPException } from "hono/http-exception";import db from "../../database";-import { taskTable } from "../../database/schema";+import { taskTable, userTable } from "../../database/schema";import { publishEvent } from "../../events";+import createNotification from "../../notification/controllers/create-notification";import { deleteOrphanedAssets } from "../../storage/cleanup-assets";+import { parseMentionIds } from "../../utils/parse-mentions";async function updateTaskDescription({id,@@ -49,6 +51,34 @@ async function updateTaskDescription({taskId: id,}).catch(() => {});+ // Notify members newly @mentioned by this edit (skip ones already mentioned+ // in the previous description, and the editor themselves).+ const alreadyMentioned = new Set(parseMentionIds(existingTask.description));+ const newlyMentioned = parseMentionIds(description).filter(+ (mentionedId) =>+ mentionedId !== currentUserId && !alreadyMentioned.has(mentionedId),+ );++ if (newlyMentioned.length > 0) {+ const [editor] = await db+ .select({ name: userTable.name })+ .from(userTable)+ .where(eq(userTable.id, currentUserId));++ for (const mentionedId of newlyMentioned) {+ await createNotification({+ userId: mentionedId,+ type: "task_mention",+ eventData: {+ taskTitle: updatedTask.title,+ mentionerName: editor?.name ?? null,+ },+ resourceId: updatedTask.id,+ resourceType: "task",+ });+ }+ }+return updatedTask;}