From 3df035b7ddc002bf5c758419a33f5c2f369716bd Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 29 Oct 2022 23:54:47 +0300 Subject: Use config settings --- vnext/server/sender.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'vnext/server') 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 -- cgit v1.2.3