@things-factory/notification 5.0.11 → 6.0.0-alpha.3
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/client/viewparts/notification-sender.js +7 -5
- package/dist-server/routers/notification-router.js +3 -3
- package/dist-server/routers/notification-router.js.map +1 -1
- package/dist-server/service/notification/notification.js +1 -2
- package/dist-server/service/notification/notification.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/server/routers/notification-router.ts +5 -3
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '@material/mwc-formfield'
|
|
2
|
+
import '@material/mwc-button'
|
|
3
|
+
import '@material/mwc-checkbox'
|
|
4
|
+
|
|
5
|
+
import { css, html, LitElement } from 'lit'
|
|
6
|
+
|
|
2
7
|
import { auth } from '@things-factory/auth-base'
|
|
3
8
|
import { i18next, localize } from '@things-factory/i18n-base'
|
|
4
9
|
import { ScrollbarStyles } from '@things-factory/styles'
|
|
5
|
-
import { notify as webpushNotify } from '../actions/notification-fcm'
|
|
6
10
|
|
|
7
|
-
import '
|
|
8
|
-
import '@material/mwc-button'
|
|
9
|
-
import '@material/mwc-checkbox'
|
|
11
|
+
import { notify as webpushNotify } from '../actions/notification-fcm'
|
|
10
12
|
|
|
11
13
|
export class NotificationSender extends localize(i18next)(LitElement) {
|
|
12
14
|
static get styles() {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.notificationRouter = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const koa_router_1 = tslib_1.__importDefault(require("koa-router"));
|
|
6
|
-
const typeorm_1 = require("typeorm");
|
|
7
6
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const fcm_1 = require("../controllers/fcm");
|
|
9
9
|
const debug = require('debug')('things-factory:notification:notification-router');
|
|
10
10
|
exports.notificationRouter = new koa_router_1.default({
|
|
@@ -29,7 +29,7 @@ exports.notificationRouter.post('/unregister', async (context, next) => {
|
|
|
29
29
|
});
|
|
30
30
|
exports.notificationRouter.post('/notify', async (context, next) => {
|
|
31
31
|
const { user, domain, notify } = context.state;
|
|
32
|
-
const repository = (0,
|
|
32
|
+
const repository = (0, shell_1.getRepository)(auth_base_1.User);
|
|
33
33
|
var _a = context.request.body, { receivers } = _a, options = tslib_1.__rest(_a, ["receivers"]);
|
|
34
34
|
debug('post:/notify', receivers, receivers.split(','), options);
|
|
35
35
|
// TODO filter only users having current domain privilege
|
|
@@ -37,7 +37,7 @@ exports.notificationRouter.post('/notify', async (context, next) => {
|
|
|
37
37
|
.split(',')
|
|
38
38
|
.map(email => email.trim())
|
|
39
39
|
.map(async (email) => {
|
|
40
|
-
var receiver = await repository.
|
|
40
|
+
var receiver = await repository.findOneBy({ email });
|
|
41
41
|
return receiver && receiver.id;
|
|
42
42
|
}))).filter(receiver => !!receiver);
|
|
43
43
|
debug('post:/notify', receivers, user.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-router.js","sourceRoot":"","sources":["../../server/routers/notification-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;
|
|
1
|
+
{"version":3,"file":"notification-router.js","sourceRoot":"","sources":["../../server/routers/notification-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAE/B,yDAAgD;AAChD,iDAAqD;AAErD,4CAAoE;AAEpE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iDAAiD,CAAC,CAAA;AAEpE,QAAA,kBAAkB,GAAG,IAAI,oBAAM,CAAC;IAC3C,MAAM,EAAE,eAAe;CACxB,CAAC,CAAA;AAEF,0BAAkB,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACxD,MAAM,MAAM,GAAG,IAAA,eAAS,GAAE,CAAA;IAE1B,OA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C,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;IAE/D,yDAAyD;IACzD,SAAS,GAAG,CACV,MAAM,OAAO,CAAC,GAAG,CACf,SAAS;SACN,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC1B,GAAG,CAAC,KAAK,EAAC,KAAK,EAAC,EAAE;QACjB,IAAI,QAAQ,GAAS,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;QAC1D,OAAO,QAAQ,IAAI,QAAQ,CAAC,EAAE,CAAA;IAChC,CAAC,CAAC,CACL,CACF,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IAEhC,KAAK,CAAC,cAAc,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA;IAEzC,MAAM,MAAM,iBACV,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IACpD,OAAO,EACV,CAAA;IAEF,OAAO,CAAC,IAAI,GAAG;QACb,OAAO,EAAE,IAAI;KACd,CAAA;AACH,CAAC,CAAC,CAAA","sourcesContent":["import Router from 'koa-router'\n\nimport { User } from '@things-factory/auth-base'\nimport { getRepository } from '@things-factory/shell'\n\nimport { getConfig, register, unregister } from '../controllers/fcm'\n\nconst debug = require('debug')('things-factory:notification:notification-router')\n\nexport const notificationRouter = new Router({\n prefix: '/notification'\n})\n\nnotificationRouter.get('/config', async (context, next) => {\n const config = getConfig()\n\n context.type = 'application/json'\n context.body = config\n})\n\nnotificationRouter.post('/register', async (context, next) => {\n const { user } = context.state\n const { body } = context.request\n context.body = await register(user, body)\n context.status = 200\n})\n\nnotificationRouter.post('/unregister', async (context, next) => {\n const { user } = context.state\n const { body } = context.request\n context.body = await unregister(user, body)\n context.status = 200\n})\n\nnotificationRouter.post('/notify', async (context, next) => {\n const { user, domain, notify } = context.state\n const repository = getRepository(User)\n\n var { receivers, ...options } = context.request.body\n\n debug('post:/notify', receivers, receivers.split(','), options)\n\n // TODO filter only users having current domain privilege\n receivers = (\n await Promise.all(\n receivers\n .split(',')\n .map(email => email.trim())\n .map(async email => {\n var receiver: User = await repository.findOneBy({ email })\n return receiver && receiver.id\n })\n )\n ).filter(receiver => !!receiver)\n\n debug('post:/notify', receivers, user.id)\n\n await notify({\n receivers: receivers.length > 0 ? receivers : [user.id],\n ...options\n })\n\n context.body = {\n success: true\n }\n})\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.Notification = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -9,7 +8,7 @@ let Notification = class Notification {
|
|
|
9
8
|
};
|
|
10
9
|
tslib_1.__decorate([
|
|
11
10
|
(0, type_graphql_1.Field)(type => shell_1.Domain, { nullable: true }),
|
|
12
|
-
tslib_1.__metadata("design:type",
|
|
11
|
+
tslib_1.__metadata("design:type", shell_1.Domain)
|
|
13
12
|
], Notification.prototype, "domain", void 0);
|
|
14
13
|
tslib_1.__decorate([
|
|
15
14
|
(0, type_graphql_1.Field)({ nullable: true }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../server/service/notification/notification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../server/service/notification/notification.ts"],"names":[],"mappings":";;;;AAAA,+CAAgD;AAChD,iDAAyD;AAGzD,IAAa,YAAY,GAAzB,MAAa,YAAY;CA2BxB,CAAA;AAzBC;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACjC,cAAM;4CAAA;AAGf;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;6CACV;AAGhB;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;0CACb;AAGb;IADC,IAAA,oBAAK,GAAE;;2CACK;AAGb;IADC,IAAA,oBAAK,GAAE;;0CACI;AAGZ;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCACf;AAGX;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;2CACb;AAGb;IADC,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;8CAChC;AAGb;IADC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACf,IAAI;+CAAA;AA1BJ,YAAY;IADxB,IAAA,yBAAU,GAAE;GACA,YAAY,CA2BxB;AA3BY,oCAAY","sourcesContent":["import { ObjectType, Field } from 'type-graphql'\nimport { Domain, ScalarAny } from '@things-factory/shell'\n\n@ObjectType()\nexport class Notification {\n @Field(type => Domain, { nullable: true })\n domain?: Domain\n\n @Field({ nullable: true })\n subject?: string\n\n @Field({ nullable: true })\n type?: string\n\n @Field()\n title: string\n\n @Field()\n body: string\n\n @Field({ nullable: true })\n url: string\n\n @Field({ nullable: true })\n image: string\n\n @Field(type => ScalarAny, { nullable: true })\n property: any\n\n @Field({ nullable: true })\n timestamp: Date\n}\n"]}
|