diff options
Diffstat (limited to 'vnext/server')
-rw-r--r-- | vnext/server/sender.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/vnext/server/sender.js b/vnext/server/sender.js index 6d88c4c0..6ece8eaa 100644 --- a/vnext/server/sender.js +++ b/vnext/server/sender.js @@ -2,34 +2,40 @@ import PushNotifications from 'node-pushnotifications'; var debug = require('debug')('sender'); import { deleteSubscribers } from './http'; import { formatMessage, formatTitle, formatQuote } from './common/MessageUtils'; +import config from 'config'; + +let cfg = /** @type { import('node-pushnotifications').Settings } */ (config); const apnConfig = (production = true) => { const apn = { + ...cfg.apn, token: { - key: process.env.JUICK_APN_KEY, - keyId: process.env.JUICK_APN_KEY_ID, - teamId: process.env.JUICK_APN_TEAM_ID + key: cfg.apn?.token?.key || process.env.JUICK_APN_KEY, + keyId: cfg.apn?.token?.keyId || process.env.JUICK_APN_KEY_ID, + teamId: cfg.apn?.token?.teamId || process.env.JUICK_APN_TEAM_ID }, production: production }; return apn; }; const gcmConfig = { - id: process.env.JUICK_GCM_ID + ...cfg.gcm, + id: cfg.gcm?.id || process.env.JUICK_GCM_ID }; const push = new PushNotifications({ + ...config, apn: apnConfig(true), gcm: gcmConfig, }); const sandbox = new PushNotifications({ + ...config, apn: apnConfig(false), gcm: gcmConfig }); /** @type {string} */ -const application = process.env.JUICK_APN_APPLICATION || ''; - +const application = config.get('service.application') || process.env.JUICK_APN_APPLICATION || ''; /** * send notification |