feature/IO-3060-Realtime-Notifications-System
- Add handlers for Job and Bill Change / Register Routers - Add Tables / Modify Tables / Add permissions.
This commit is contained in:
@@ -207,6 +207,7 @@
|
|||||||
- default_prod_list_view
|
- default_prod_list_view
|
||||||
- id
|
- id
|
||||||
- kanban_settings
|
- kanban_settings
|
||||||
|
- notification_settings
|
||||||
- qbo_realmId
|
- qbo_realmId
|
||||||
- shopid
|
- shopid
|
||||||
- useremail
|
- useremail
|
||||||
@@ -222,6 +223,7 @@
|
|||||||
- authlevel
|
- authlevel
|
||||||
- default_prod_list_view
|
- default_prod_list_view
|
||||||
- kanban_settings
|
- kanban_settings
|
||||||
|
- notification_settings
|
||||||
- qbo_realmId
|
- qbo_realmId
|
||||||
filter:
|
filter:
|
||||||
user:
|
user:
|
||||||
@@ -2805,6 +2807,80 @@
|
|||||||
_eq: X-Hasura-User-Id
|
_eq: X-Hasura-User-Id
|
||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
|
- table:
|
||||||
|
name: job_watchers
|
||||||
|
schema: public
|
||||||
|
object_relationships:
|
||||||
|
- name: job
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: job_id
|
||||||
|
- name: user
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: user_email
|
||||||
|
insert_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
check:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
columns:
|
||||||
|
- user_email
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- job_id
|
||||||
|
comment: ""
|
||||||
|
select_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- user_email
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- job_id
|
||||||
|
filter:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
comment: ""
|
||||||
|
update_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- user_email
|
||||||
|
- created_at
|
||||||
|
- id
|
||||||
|
- job_id
|
||||||
|
filter:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
check: null
|
||||||
|
comment: ""
|
||||||
|
delete_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
filter:
|
||||||
|
user:
|
||||||
|
_and:
|
||||||
|
- associations:
|
||||||
|
active:
|
||||||
|
_eq: true
|
||||||
|
- authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
comment: ""
|
||||||
- table:
|
- table:
|
||||||
name: joblines
|
name: joblines
|
||||||
schema: public
|
schema: public
|
||||||
@@ -4669,6 +4745,95 @@
|
|||||||
_eq: X-Hasura-User-Id
|
_eq: X-Hasura-User-Id
|
||||||
- active:
|
- active:
|
||||||
_eq: true
|
_eq: true
|
||||||
|
- table:
|
||||||
|
name: notifications
|
||||||
|
schema: public
|
||||||
|
object_relationships:
|
||||||
|
- name: association
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: association_id
|
||||||
|
- name: job
|
||||||
|
using:
|
||||||
|
foreign_key_constraint_on: job_id
|
||||||
|
insert_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
check:
|
||||||
|
association:
|
||||||
|
_and:
|
||||||
|
- active:
|
||||||
|
_eq: true
|
||||||
|
- user:
|
||||||
|
authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
columns:
|
||||||
|
- association_id
|
||||||
|
- created_at
|
||||||
|
- fcm_data
|
||||||
|
- fcm_message
|
||||||
|
- fcm_title
|
||||||
|
- id
|
||||||
|
- job_id
|
||||||
|
- meta
|
||||||
|
- read
|
||||||
|
- scenario
|
||||||
|
- ui_translation_meta
|
||||||
|
- ui_translation_string
|
||||||
|
- updated_at
|
||||||
|
comment: ""
|
||||||
|
select_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- association_id
|
||||||
|
- created_at
|
||||||
|
- fcm_data
|
||||||
|
- fcm_message
|
||||||
|
- fcm_title
|
||||||
|
- id
|
||||||
|
- job_id
|
||||||
|
- meta
|
||||||
|
- read
|
||||||
|
- scenario
|
||||||
|
- ui_translation_meta
|
||||||
|
- ui_translation_string
|
||||||
|
- updated_at
|
||||||
|
filter:
|
||||||
|
association:
|
||||||
|
_and:
|
||||||
|
- active:
|
||||||
|
_eq: true
|
||||||
|
- user:
|
||||||
|
authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
comment: ""
|
||||||
|
update_permissions:
|
||||||
|
- role: user
|
||||||
|
permission:
|
||||||
|
columns:
|
||||||
|
- association_id
|
||||||
|
- created_at
|
||||||
|
- fcm_data
|
||||||
|
- fcm_message
|
||||||
|
- fcm_title
|
||||||
|
- id
|
||||||
|
- job_id
|
||||||
|
- meta
|
||||||
|
- read
|
||||||
|
- scenario
|
||||||
|
- ui_translation_meta
|
||||||
|
- ui_translation_string
|
||||||
|
- updated_at
|
||||||
|
filter:
|
||||||
|
association:
|
||||||
|
_and:
|
||||||
|
- active:
|
||||||
|
_eq: true
|
||||||
|
- user:
|
||||||
|
authid:
|
||||||
|
_eq: X-Hasura-User-Id
|
||||||
|
check: null
|
||||||
|
comment: ""
|
||||||
- table:
|
- table:
|
||||||
name: owners
|
name: owners
|
||||||
schema: public
|
schema: public
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- alter table "public"."associations" add column "notification_settings" jsonb
|
||||||
|
-- null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."associations" add column "notification_settings" jsonb
|
||||||
|
null;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE "public"."notifications";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE TABLE "public"."notifications" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "job_id" uuid NOT NULL, "association_id" uuid NOT NULL, "ui_translation_string" text NOT NULL, "ui_translation_meta" jsonb, "fcm_title" text NOT NULL, "fcm_message" text NOT NULL, "fcm_data" jsonb, "read" timestamptz, "meta" jsonb, "scenario" Integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("job_id") REFERENCES "public"."jobs"("id") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("association_id") REFERENCES "public"."associations"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id"));COMMENT ON TABLE "public"."notifications" IS E'Real Time Notifications System';
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
comment on column "public"."notifications"."scenario" is E'Real Time Notifications System';
|
||||||
|
alter table "public"."notifications" alter column "scenario" drop not null;
|
||||||
|
alter table "public"."notifications" add column "scenario" int4;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
alter table "public"."notifications" drop column "scenario" cascade;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-- Could not auto-generate a down migration.
|
||||||
|
-- Please write an appropriate down migration for the SQL below:
|
||||||
|
-- alter table "public"."notifications" add column "scenario" text
|
||||||
|
-- not null;
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
alter table "public"."notifications" add column "scenario" text
|
||||||
|
not null;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DROP TABLE "public"."job_watchers";
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
CREATE TABLE "public"."job_watchers" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "job_id" uuid NOT NULL, "user_email" text NOT NULL, "created_at" timestamptz NOT NULL DEFAULT now(), PRIMARY KEY ("id") , FOREIGN KEY ("user_email") REFERENCES "public"."users"("email") ON UPDATE restrict ON DELETE restrict, FOREIGN KEY ("job_id") REFERENCES "public"."jobs"("id") ON UPDATE restrict ON DELETE restrict, UNIQUE ("id"));COMMENT ON TABLE "public"."job_watchers" IS E'Job Watchers';
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pgcrypto;
|
||||||
5
server/notifications/eventHandlers/handeJobChange.js
Normal file
5
server/notifications/eventHandlers/handeJobChange.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const handleJobChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Job change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handleJobChange;
|
||||||
5
server/notifications/eventHandlers/handleBillChange.js
Normal file
5
server/notifications/eventHandlers/handleBillChange.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const handleBillChange = (req, res) => {
|
||||||
|
return res.status(200).json({ message: "Bill change handled." });
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = handleBillChange;
|
||||||
@@ -1,12 +1,19 @@
|
|||||||
const express = require("express");
|
const express = require("express");
|
||||||
const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware");
|
const validateFirebaseIdTokenMiddleware = require("../middleware/validateFirebaseIdTokenMiddleware");
|
||||||
const { subscribe, unsubscribe, sendNotification } = require("../firebase/firebase-handler");
|
const { subscribe, unsubscribe, sendNotification } = require("../firebase/firebase-handler");
|
||||||
|
const eventAuthorizationMiddleware = require("../middleware/eventAuthorizationMIddleware");
|
||||||
|
const handleJobChange = require("../notifications/eventHandlers/handeJobChange");
|
||||||
|
const handleBillChange = require("../notifications/eventHandlers/handleBillChange");
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
router.use(validateFirebaseIdTokenMiddleware);
|
// These are FCM handlers
|
||||||
|
router.post("/subscribe", validateFirebaseIdTokenMiddleware, subscribe);
|
||||||
|
router.post("/unsubscribe", validateFirebaseIdTokenMiddleware, unsubscribe);
|
||||||
|
router.post("/sendtestnotification", validateFirebaseIdTokenMiddleware, sendNotification);
|
||||||
|
|
||||||
router.post("/subscribe", subscribe);
|
// Hasura Entry points for creating notifications
|
||||||
router.post("/unsubscribe", unsubscribe);
|
router.post("/events/handleJobChange", eventAuthorizationMiddleware, handleJobChange);
|
||||||
router.post("/sendtestnotification", sendNotification);
|
router.post("/events/handleBillChange", eventAuthorizationMiddleware, handleBillChange);
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|||||||
Reference in New Issue
Block a user