feat: send alerts to specific users when requests field is updated in permits collection
This commit is contained in:
@@ -276,6 +276,26 @@ export async function updatePermit(
|
|||||||
"permits"
|
"permits"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (key == "requests" && input[key] != null) {
|
||||||
|
const requestAlertsUsers = [
|
||||||
|
"6830d9ac46971e8148fda973", //Lucy
|
||||||
|
"67c717024871a88b9ee54f55", //Ashlee
|
||||||
|
"67f53b557b41964444a74095", //Khran
|
||||||
|
"67db2803502dafae0d705519", //Joe
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const userId of requestAlertsUsers) {
|
||||||
|
await createAlert(
|
||||||
|
user.tenantId,
|
||||||
|
`Request updated`,
|
||||||
|
"user",
|
||||||
|
userId,
|
||||||
|
updatePermitResult.pid,
|
||||||
|
"permits"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (key == "client") {
|
} else if (key == "client") {
|
||||||
const orgInDb = await orgModel.findById(input.client);
|
const orgInDb = await orgModel.findById(input.client);
|
||||||
if (orgInDb) {
|
if (orgInDb) {
|
||||||
|
|||||||
Reference in New Issue
Block a user