feat: populate assignedTo field for get notification response
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
|||||||
getTaggedUsersFilter,
|
getTaggedUsersFilter,
|
||||||
PageQueryParams,
|
PageQueryParams,
|
||||||
} from "../pagination";
|
} from "../pagination";
|
||||||
import { userModel } from "../user/user.schema";
|
|
||||||
import { generateId } from "../utils/id";
|
import { generateId } from "../utils/id";
|
||||||
import {
|
import {
|
||||||
CreateNotificationInput,
|
CreateNotificationInput,
|
||||||
@@ -39,10 +38,12 @@ export async function getNotification(
|
|||||||
notifId: string,
|
notifId: string,
|
||||||
user: AuthenticatedUser
|
user: AuthenticatedUser
|
||||||
) {
|
) {
|
||||||
return await notificationModel.findOne({
|
return await notificationModel
|
||||||
|
.findOne({
|
||||||
tenantId: user.tenantId,
|
tenantId: user.tenantId,
|
||||||
pid: notifId,
|
pid: notifId,
|
||||||
});
|
})
|
||||||
|
.populate({ path: "assignedTo", select: "pid name avatar" });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateNotification(
|
export async function updateNotification(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
} from "./processed.schema";
|
} from "./processed.schema";
|
||||||
import { createNote } from "../note/note.service";
|
import { createNote } from "../note/note.service";
|
||||||
import { createAlert } from "../alert/alert.service";
|
import { createAlert } from "../alert/alert.service";
|
||||||
|
import { getUser } from "../user/user.service";
|
||||||
|
|
||||||
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
export async function getProcessedPermit(permitId: String, tenantId: String) {
|
||||||
return await processedModel
|
return await processedModel
|
||||||
@@ -48,6 +49,11 @@ export async function updateProcessed(
|
|||||||
|
|
||||||
if (input[key] === null) {
|
if (input[key] === null) {
|
||||||
msg = `Cleared ${key}`;
|
msg = `Cleared ${key}`;
|
||||||
|
} else if (key == "assignedTo") {
|
||||||
|
const user = await getUser(input.assignedTo);
|
||||||
|
if (!user) continue;
|
||||||
|
|
||||||
|
msg = `Assigned to ${user.firstName + " " + user.lastName}`;
|
||||||
} else {
|
} else {
|
||||||
msg = `Updated ${key} to '${input[key]}'`;
|
msg = `Updated ${key} to '${input[key]}'`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user