feature/IO-3096-GlobalNotifications - Check-point

This commit is contained in:
Dave Richer
2025-02-11 10:40:57 -05:00
parent 54820fe3c8
commit 2ee582bfa2
9 changed files with 156 additions and 91 deletions

View File

@@ -0,0 +1,6 @@
const consoleDir = require("../../utils/consoleDir");
const jobAssignedToMeBuilder = (data) => {
consoleDir(data);
};
module.exports = jobAssignedToMeBuilder;

View File

@@ -1,64 +1,47 @@
const consoleDir = require("../../utils/consoleDir");
const { sendTaskEmail } = require("../../email/sendemail");
// {
// "changedFieldNames": [
// "description",
// "updated_at"
// ],
// "changedFields": {
// "description": "sadasdasdasdsadssdsaddddsdsd",
// "updated_at": "2025-02-10T19:20:34.195086+00:00"
// },
// "isNew": false,
// "data": {
// "assigned_to": "5e4f78a2-0f23-4e7e-920c-02a4e016b398",
// "billid": null,
// "bodyshopid": "71f8494c-89f0-43e0-8eb2-820b52d723bc",
// "completed": false,
// "completed_at": null,
// "created_at": "2025-02-09T20:02:46.839271+00:00",
// "created_by": "dave@imex.dev",
// "deleted": false,
// "deleted_at": null,
// "description": "sadasdasdasdsadssdsaddddsdsd",
// "due_date": null,
// "id": "ca1c49a9-3c26-46cb-bebd-4b93f02cad2a",
// "jobid": "ec1c26c7-b0ea-493f-9bba-30efc291e0fa",
// "joblineid": "84b5bbf9-ab57-4c77-abb0-8fdd8709c9ff",
// "partsorderid": null,
// "priority": 2,
// "remind_at": null,
// "remind_at_sent": null,
// "title": "sd",
// "updated_at": "2025-02-10T19:20:34.195086+00:00"
// },
// "trigger": {
// "name": "notifications_tasks"
// },
// "table": {
// "name": "tasks",
// "schema": "public"
// },
// "jobId": "ec1c26c7-b0ea-493f-9bba-30efc291e0fa",
// "watchers": [
// "dave@imex.dev"
// ],
// "bodyShopId": "71f8494c-89f0-43e0-8eb2-820b52d723bc",
// "bodyShopName": "Rome Online Collision DEMO"
// }
// node-app | {
// node-app | trigger: 'notifications_tasks',
// node-app | bodyShopId: '71f8494c-89f0-43e0-8eb2-820b52d723bc',
// node-app | bodyShopName: 'Rome Online Collision DEMO',
// node-app | scenarioKey: 'tasks-updated-created',
// node-app | scenarioTable: 'tasks',
// node-app | scenarioFields: [ 'updated_at' ],
// node-app | scenarioBuilder: [AsyncFunction: tasksUpdatedCreatedBuilder],
// node-app | scenarioWatchers: [ { user: 'dave@imex.dev', email: true, app: true, fcm: undefined } ],
// node-app | jobId: 'ec1c26c7-b0ea-493f-9bba-30efc291e0fa',
// node-app | isNew: false,
// node-app | changedFieldNames: [ 'description', 'updated_at' ],
// node-app | changedFields: {
// node-app | description: 'sadasdasdasdsadssdsaddddsdsddddddddddddsdsdddsddddddddddd',
// node-app | updated_at: '2025-02-10T23:02:21.244722+00:00'
// node-app | },
// node-app | data: {
// node-app | assigned_to: '5e4f78a2-0f23-4e7e-920c-02a4e016b398',
// node-app | billid: null,
// node-app | bodyshopid: '71f8494c-89f0-43e0-8eb2-820b52d723bc',
// node-app | completed: false,
// node-app | completed_at: null,
// node-app | created_at: '2025-02-09T20:02:46.839271+00:00',
// node-app | created_by: 'dave@imex.dev',
// node-app | deleted: false,
// node-app | deleted_at: null,
// node-app | description: 'sadasdasdasdsadssdsaddddsdsddddddddddddsdsdddsddddddddddd',
// node-app | due_date: null,
// node-app | id: 'ca1c49a9-3c26-46cb-bebd-4b93f02cad2a',
// node-app | jobid: 'ec1c26c7-b0ea-493f-9bba-30efc291e0fa',
// node-app | joblineid: '84b5bbf9-ab57-4c77-abb0-8fdd8709c9ff',
// node-app | partsorderid: null,
// node-app | priority: 2,
// node-app | remind_at: null,
// node-app | remind_at_sent: null,
// node-app | title: 'sd',
// node-app | updated_at: '2025-02-10T23:02:21.244722+00:00'
// node-app | }
// node-app | }
const tasksUpdatedCreatedBuilder = async (data) => {
consoleDir(data);
// Step 0: Check to see if the users are watching the current scenario
// Step 1: Dispatch Email to all watchers
// sendTaskEmail({
// bcc: data.watchers,
// subject: `Task Updated: ${data.data.title}`,
// text: `Task Updated: ${data.data.title}`
// });
// Step 2: Send notification and basic paramaters to a real time job queue to debounce potential multiple notifications
};
module.exports = tasksUpdatedCreatedBuilder;