aboutsummaryrefslogtreecommitdiff
path: root/vnext/server/sender.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/server/sender.js')
-rw-r--r--vnext/server/sender.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/vnext/server/sender.js b/vnext/server/sender.js
index 6ece8eaa..f33eadcf 100644
--- a/vnext/server/sender.js
+++ b/vnext/server/sender.js
@@ -1,5 +1,6 @@
import PushNotifications from 'node-pushnotifications';
-var debug = require('debug')('sender');
+import debug from 'debug';
+const log = debug('sender');
import { deleteSubscribers } from './http';
import { formatMessage, formatTitle, formatQuote } from './common/MessageUtils';
import config from 'config';
@@ -51,7 +52,7 @@ export function sendNotification(productionIds, sandboxIds, data) {
sender.send(registrationIds, data)
.then((results) => {
results.forEach(result => {
- debug(`${result.method}: ${result.success} success, ${result.failure} failure`);
+ log(`${result.method}: ${result.success} success, ${result.failure} failure`);
if (result.failure) {
console.error(`${result.method} failure: ${JSON.stringify(result)}`);
console.error(`Failed data: ${JSON.stringify(data)}`);
@@ -59,13 +60,13 @@ export function sendNotification(productionIds, sandboxIds, data) {
});
results.filter(r => r.method === 'apn')
.forEach(async r => {
- debug(`Response message: ${JSON.stringify(r.message)}`);
+ log(`Response message: ${JSON.stringify(r.message)}`);
let badTokens = r.message.filter(m => m.errorMsg === 'BadDeviceToken').map(m => {
return { 'type': 'apns', 'token': m.regId };
});
if (badTokens.length > 0) {
await deleteSubscribers(badTokens);
- debug(`${badTokens.length} APNS tokens deleted`);
+ log(`${badTokens.length} APNS tokens deleted`);
}
});
results.filter(r => r.method === 'gcm')
@@ -75,7 +76,7 @@ export function sendNotification(productionIds, sandboxIds, data) {
});
if (badTokens.length > 0) {
await deleteSubscribers(badTokens);
- debug(`${badTokens.length} GCM tokens deleted`);
+ log(`${badTokens.length} GCM tokens deleted`);
}
});
results.filter(r => r.method === 'mpns')
@@ -85,7 +86,7 @@ export function sendNotification(productionIds, sandboxIds, data) {
});
if (badTokens.length > 0) {
await deleteSubscribers(badTokens);
- debug(`${badTokens.length} MPNS tokens deleted`);
+ log(`${badTokens.length} MPNS tokens deleted`);
}
});
})
@@ -136,7 +137,5 @@ export function buildNotification(user, msg) {
template.tag = `${tag}`;
template.android_channel_id = 'default';
}
- // FIXME: wrong type definition in node-pushnotifications: title and body and not required for silent pushes
- // @ts-ignore
return template;
}