|
|
@ -33,6 +33,10 @@ var PUSHNOTIFICATIONS_TYPES = { |
|
|
|
'TxProposalFinallyRejected': { |
|
|
|
filename: 'txp_finally_rejected', |
|
|
|
}, |
|
|
|
'TxConfirmation': { |
|
|
|
filename: 'tx_confirmation', |
|
|
|
notifyCreatorOnly: true, |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
function PushNotificationsService() {}; |
|
|
@ -111,7 +115,7 @@ PushNotificationsService.prototype._sendPushNotifications = function(notificatio |
|
|
|
log.debug('Should send notification: ', should); |
|
|
|
if (!should) return cb(); |
|
|
|
|
|
|
|
self._getRecipientsList(notification, function(err, recipientsList) { |
|
|
|
self._getRecipientsList(notification, notifType, function(err, recipientsList) { |
|
|
|
if (err) return cb(err); |
|
|
|
|
|
|
|
async.waterfall([ |
|
|
@ -188,7 +192,7 @@ PushNotificationsService.prototype._checkShouldSendNotif = function(notification |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
PushNotificationsService.prototype._getRecipientsList = function(notification, cb) { |
|
|
|
PushNotificationsService.prototype._getRecipientsList = function(notification, notificationType, cb) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
self.storage.fetchWallet(notification.walletId, function(err, wallet) { |
|
|
@ -216,16 +220,19 @@ PushNotificationsService.prototype._getRecipientsList = function(notification, c |
|
|
|
|
|
|
|
recipientPreferences = _.indexBy(recipientPreferences, 'copayerId'); |
|
|
|
|
|
|
|
var recipientsList = _.reject(_.map(wallet.copayers, function(copayer) { |
|
|
|
var p = recipientPreferences[copayer.id] || {}; |
|
|
|
return { |
|
|
|
copayerId: copayer.id, |
|
|
|
language: p.language || self.defaultLanguage, |
|
|
|
unit: p.unit || self.defaultUnit, |
|
|
|
var recipientsList = _.compact(_.map(wallet.copayers, function(copayer) { |
|
|
|
if ((copayer.id == notification.creatorId && notificationType.notifyCreatorOnly) || |
|
|
|
(copayer.id != notification.creatorId && !notificationType.notifyCreatorOnly)) { |
|
|
|
var p = recipientPreferences[copayer.id] || {}; |
|
|
|
return { |
|
|
|
copayerId: copayer.id, |
|
|
|
language: p.language || self.defaultLanguage, |
|
|
|
unit: p.unit || self.defaultUnit, |
|
|
|
} |
|
|
|
} |
|
|
|
}), { |
|
|
|
copayerId: notification.creatorId |
|
|
|
}); |
|
|
|
})); |
|
|
|
console.log('*** [pushnotificationsservice.js ln234] recipientsList:', recipientsList); // TODO
|
|
|
|
|
|
|
|
|
|
|
|
return cb(null, recipientsList); |
|
|
|
}); |
|
|
|