@things-factory/notification 6.2.86 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/notification/notification-subscription.js +18 -16
- package/dist-server/service/notification/notification-subscription.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- package/server/service/notification/notification-subscription.ts +27 -27
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationSubscription = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const graphql_yoga_1 = require("graphql-yoga");
|
|
6
6
|
const type_graphql_1 = require("type-graphql");
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const notification_1 = require("./notification");
|
|
@@ -13,24 +13,26 @@ let NotificationSubscription = class NotificationSubscription {
|
|
|
13
13
|
};
|
|
14
14
|
tslib_1.__decorate([
|
|
15
15
|
(0, type_graphql_1.Subscription)({
|
|
16
|
-
subscribe: (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
16
|
+
subscribe: ({ args, context, info }) => {
|
|
17
|
+
const { subjects = [] } = args;
|
|
18
|
+
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('notification'), (0, graphql_yoga_1.filter)(async (payload) => {
|
|
19
|
+
/* normally, subscription context doesn't have domain */
|
|
20
|
+
const { domain, user } = context.state;
|
|
21
|
+
const { notification: { subject, domain: pdomain } } = payload;
|
|
22
|
+
const subdomain = pdomain === null || pdomain === void 0 ? void 0 : pdomain.subdomain;
|
|
23
|
+
if (subdomain) {
|
|
24
|
+
if (domain === null || domain === void 0 ? void 0 : domain.subdomain) {
|
|
25
|
+
if (subdomain !== domain.subdomain) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (!user.domains.find(d => d.subdomain === subdomain)) {
|
|
25
30
|
return false;
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
return !subject || subjects.indexOf(subject) !== -1;
|
|
33
|
-
})
|
|
33
|
+
return !subject || subjects.indexOf(subject) !== -1;
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
34
36
|
}),
|
|
35
37
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
36
38
|
tslib_1.__param(1, (0, type_graphql_1.Arg)('subjects', type => [String], { nullable: true })),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-subscription.js","sourceRoot":"","sources":["../../../server/service/notification/notification-subscription.ts"],"names":[],"mappings":";;;;AAAA
|
|
1
|
+
{"version":3,"file":"notification-subscription.js","sourceRoot":"","sources":["../../../server/service/notification/notification-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAA2C;AAC3C,+CAA+E;AAE/E,iDAA0D;AAE1D,iDAA6C;AAGtC,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IAgCnC,YAAY,CAAS,OAAuC,EAAyD,QAAkB;QACrI,OAAO,OAAO,CAAC,YAAY,CAAA;IAC7B,CAAC;CACF,CAAA;AAlCC;IAAC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;YACrC,MAAM,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,IAAI,CAAA;YAE9B,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,cAAc,CAAC,EAChC,IAAA,qBAAM,EAAC,KAAK,EAAE,OAAuC,EAAE,EAAE;gBACvD,wDAAwD;gBACxD,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;gBAEtC,MAAM,EACJ,YAAY,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,EAC3C,GAAG,OAAO,CAAA;gBAEX,MAAM,SAAS,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,SAAS,CAAA;gBAEpC,IAAI,SAAS,EAAE;oBACb,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,EAAE;wBACrB,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,EAAE;4BAClC,OAAO,KAAK,CAAA;yBACb;qBACF;yBAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,EAAE;wBAC7D,OAAO,KAAK,CAAA;qBACb;iBACF;gBAED,OAAO,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;YACrD,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACY,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAA2C,mBAAA,IAAA,kBAAG,EAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;4CAAsB,2BAAY;4DAErJ;AAlCU,wBAAwB;IADpC,IAAA,uBAAQ,EAAC,2BAAY,CAAC;GACV,wBAAwB,CAmCpC;AAnCY,4DAAwB","sourcesContent":["import { filter, pipe } from 'graphql-yoga'\nimport { Arg, Resolver, FieldResolver, Root, Subscription } from 'type-graphql'\n\nimport { pubsub, ScalarDate } from '@things-factory/shell'\n\nimport { Notification } from './notification'\n\n@Resolver(Notification)\nexport class NotificationSubscription {\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { subjects = [] } = args\n\n return pipe(\n pubsub.subscribe('notification'),\n filter(async (payload: { notification: Notification }) => {\n /* normally, subscription context doesn't have domain */\n const { domain, user } = context.state\n\n const {\n notification: { subject, domain: pdomain }\n } = payload\n\n const subdomain = pdomain?.subdomain\n\n if (subdomain) {\n if (domain?.subdomain) {\n if (subdomain !== domain.subdomain) {\n return false\n }\n } else if (!user.domains.find(d => d.subdomain === subdomain)) {\n return false\n }\n }\n\n return !subject || subjects.indexOf(subject) !== -1\n })\n )\n }\n })\n notification(@Root() payload: { notification: Notification }, @Arg('subjects', type => [String], { nullable: true }) subjects: string[]): Notification {\n return payload.notification\n }\n}\n"]}
|