Merged in feature/IO-3487-Auto-Add-Profile-Watchers (pull request #2740)
feature/IO-3487-Auto-Add-Profile-Watchers - Fix Auto Add on a profile level
This commit is contained in:
@@ -3089,17 +3089,19 @@ exports.INSERT_JOB_WATCHERS = `
|
||||
`;
|
||||
|
||||
exports.GET_NOTIFICATION_WATCHERS = `
|
||||
query GET_NOTIFICATION_WATCHERS($shopId: uuid!, $employeeIds: [uuid!]!) {
|
||||
query GET_NOTIFICATION_WATCHERS($shopId: uuid!, $employeeIds: [uuid!]!, $createdUserEmail: String!) {
|
||||
associations(where: {
|
||||
_and: [
|
||||
{ shopid: { _eq: $shopId } },
|
||||
{ active: { _eq: true } },
|
||||
{ notifications_autoadd: { _eq: true } }
|
||||
{ notifications_autoadd: { _eq: true } },
|
||||
{ useremail: { _eq: $createdUserEmail } }
|
||||
]
|
||||
}) {
|
||||
id
|
||||
useremail
|
||||
}
|
||||
|
||||
employees(where: { id: { _in: $employeeIds }, shopid: { _eq: $shopId }, active: { _eq: true } }) {
|
||||
user_email
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ const autoAddWatchers = async (req) => {
|
||||
const jobId = event?.data?.new?.id;
|
||||
const shopId = event?.data?.new?.shopid;
|
||||
const roNumber = event?.data?.new?.ro_number || "unknown";
|
||||
const createdUserEmail = event?.data?.new?.created_user_email || "Unknown";
|
||||
|
||||
if (!jobId || !shopId) {
|
||||
throw new Error(`Missing jobId (${jobId}) or shopId (${shopId}) for auto-add watchers`);
|
||||
@@ -61,7 +62,8 @@ const autoAddWatchers = async (req) => {
|
||||
const [notificationData, existingWatchersData] = await Promise.all([
|
||||
gqlClient.request(GET_NOTIFICATION_WATCHERS, {
|
||||
shopId,
|
||||
employeeIds: notificationFollowers
|
||||
employeeIds: notificationFollowers,
|
||||
createdUserEmail
|
||||
}),
|
||||
gqlClient.request(GET_JOB_WATCHERS_MINIMAL, { jobid: jobId })
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user