From b68ab704da9a0cca4848991e557d105f73e08263 Mon Sep 17 00:00:00 2001 From: Akhil Meka Date: Wed, 24 Sep 2025 12:36:08 +0530 Subject: [PATCH] feat: populate assignedTo field for get notification response --- src/notification/notification.service.ts | 11 ++++++----- src/processed/processed.service.ts | 6 ++++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/notification/notification.service.ts b/src/notification/notification.service.ts index 8366e8b..82377b6 100644 --- a/src/notification/notification.service.ts +++ b/src/notification/notification.service.ts @@ -7,7 +7,6 @@ import { getTaggedUsersFilter, PageQueryParams, } from "../pagination"; -import { userModel } from "../user/user.schema"; import { generateId } from "../utils/id"; import { CreateNotificationInput, @@ -39,10 +38,12 @@ export async function getNotification( notifId: string, user: AuthenticatedUser ) { - return await notificationModel.findOne({ - tenantId: user.tenantId, - pid: notifId, - }); + return await notificationModel + .findOne({ + tenantId: user.tenantId, + pid: notifId, + }) + .populate({ path: "assignedTo", select: "pid name avatar" }); } export async function updateNotification( diff --git a/src/processed/processed.service.ts b/src/processed/processed.service.ts index a75c47e..aec4b31 100644 --- a/src/processed/processed.service.ts +++ b/src/processed/processed.service.ts @@ -13,6 +13,7 @@ import { } from "./processed.schema"; import { createNote } from "../note/note.service"; import { createAlert } from "../alert/alert.service"; +import { getUser } from "../user/user.service"; export async function getProcessedPermit(permitId: String, tenantId: String) { return await processedModel @@ -48,6 +49,11 @@ export async function updateProcessed( if (input[key] === null) { msg = `Cleared ${key}`; + } else if (key == "assignedTo") { + const user = await getUser(input.assignedTo); + if (!user) continue; + + msg = `Assigned to ${user.firstName + " " + user.lastName}`; } else { msg = `Updated ${key} to '${input[key]}'`; }