@things-factory/notification 6.0.0-alpha.13 → 6.0.0-alpha.20

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.
@@ -1,6 +1,7 @@
1
1
  import '@material/mwc-formfield'
2
2
  import '@material/mwc-button'
3
3
  import '@material/mwc-checkbox'
4
+ import '@operato/i18n/ox-i18n.js'
4
5
 
5
6
  import { css, html, LitElement } from 'lit'
6
7
 
@@ -89,11 +90,11 @@ export class NotificationSender extends localize(i18next)(LitElement) {
89
90
 
90
91
  <div buttons>
91
92
  <mwc-button raised icon="send" @click=${e => this.ontest()}>
92
- <i18n-msg msgid="button.notification-send"> </i18n-msg>
93
+ <ox-i18n msgid="button.notification-send"> </ox-i18n>
93
94
  </mwc-button>
94
95
 
95
96
  <mwc-button type="reset" outlined @click=${e => this.onreset()}>
96
- <i18n-msg msgid="button.reset"> </i18n-msg>
97
+ <ox-i18n msgid="button.reset"> </ox-i18n>
97
98
  </mwc-button>
98
99
  </div>
99
100
  </form>
@@ -3,6 +3,7 @@ import './notification-sender'
3
3
  import '@material/mwc-formfield'
4
4
  import '@material/mwc-switch'
5
5
  import '@material/mwc-button'
6
+ import '@operato/i18n/ox-i18n.js'
6
7
 
7
8
  import Clipboard from 'clipboard'
8
9
  import { css, html, LitElement } from 'lit'
@@ -71,7 +72,7 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
71
72
 
72
73
  return html`
73
74
  <setting-let>
74
- <i18n-msg slot="title" msgid="title.notification subscription"></i18n-msg>
75
+ <oxi18n slot="title" msgid="title.notification subscription"></oxi18n>
75
76
 
76
77
  ${supported
77
78
  ? html`
@@ -85,12 +86,12 @@ export class NotificationSettingLet extends localize(i18next)(LitElement) {
85
86
  </div>
86
87
 
87
88
  <div slot="content" info>
88
- <label for="subscription-token"><i18n-msg msgid="label.subscription token"></i18n-msg></label>
89
+ <label for="subscription-token"><oxi18n msgid="label.subscription token"></oxi18n></label>
89
90
  <input id="subscription-token" type="text" name="subscription-token" .value=${
90
91
  this.subscription || ''
91
92
  } readonly />
92
93
  <mwc-button dense unelevated button-in-field clipboard-copy @click=${e =>
93
- e.preventDefault()}><i18n-msg msgid="button.copy"></mwc-button>
94
+ e.preventDefault()}><oxi18n msgid="button.copy"></mwc-button>
94
95
  </div>
95
96
  `
96
97
  : html` <div slot="content">${i18next.t('text.push notification is not supported in your browser')}</div>`}
@@ -3,6 +3,7 @@ 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");
6
7
  const auth_base_1 = require("@things-factory/auth-base");
7
8
  const shell_1 = require("@things-factory/shell");
8
9
  const fcm_1 = require("../controllers/fcm");
@@ -37,7 +38,7 @@ exports.notificationRouter.post('/notify', async (context, next) => {
37
38
  .split(',')
38
39
  .map(email => email.trim())
39
40
  .map(async (email) => {
40
- var receiver = await repository.findOneBy({ email });
41
+ var receiver = await repository.findOneBy({ email: (0, typeorm_1.ILike)(email) });
41
42
  return receiver && receiver.id;
42
43
  }))).filter(receiver => !!receiver);
43
44
  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;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,OAAO,CAAC,IA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C,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
+ {"version":3,"file":"notification-router.js","sourceRoot":"","sources":["../../server/routers/notification-router.ts"],"names":[],"mappings":";;;;AAAA,oEAA+B;AAC/B,qCAA+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,OAAO,CAAC,IAAI,GAAG,kBAAkB,CAAA;IACjC,OAAO,CAAC,IAAI,GAAG,MAAM,CAAA;AACvB,CAAC,CAAC,CAAA;AAEF,0BAAkB,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAC9B,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;IAChC,OAAO,CAAC,IAAI,GAAG,MAAM,IAAA,cAAQ,EAAC,IAAI,EA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,EAAE,CAAC,CAAA;QACxE,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'\nimport { ILike } from 'typeorm'\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: ILike(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"]}