|
|
@ -49,11 +49,14 @@ var PUSHNOTIFICATIONS_TYPES = { |
|
|
|
function PushNotificationsService() {}; |
|
|
|
|
|
|
|
PushNotificationsService.prototype.start = function(opts, cb) { |
|
|
|
|
|
|
|
opts = opts || {}; |
|
|
|
var self = this; |
|
|
|
|
|
|
|
async.parallel([ |
|
|
|
function(done) { |
|
|
|
self.messageBroker = opts.messageBroker || new MessageBroker(opts.messageBrokerOpts); |
|
|
|
self.messageBroker.onMessage(_.bind(self.sendPushNotification, self)); |
|
|
|
self.messageBroker.onMessage(_.bind(self.sendPushNotifications, self)); |
|
|
|
done(); |
|
|
|
}, |
|
|
|
], function(err) { |
|
|
@ -66,8 +69,8 @@ PushNotificationsService.prototype.start = function(opts, cb) { |
|
|
|
|
|
|
|
PushNotificationsService.prototype.sendPushNotifications = function(notification, cb) { |
|
|
|
console.log(notification); |
|
|
|
if (PUSHNOTIFICATIONS_TYPES[notification.type] == notification.type) { |
|
|
|
|
|
|
|
if (PUSHNOTIFICATIONS_TYPES[notification.type]) { |
|
|
|
if (notification.type == 'NewIncomingTx') { |
|
|
|
var opts = {}; |
|
|
|
opts.users = [notification.walletId]; |
|
|
@ -112,13 +115,13 @@ PushNotificationsService.prototype.sendPushNotifications = function(notification |
|
|
|
// }
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
if (notification.type == ' NewTxProposal') { |
|
|
|
if (notification.type == 'NewTxProposal') { |
|
|
|
var opts = {}; |
|
|
|
opts.users = [notification.walletId]; |
|
|
|
opts.android = { |
|
|
|
"collapseKey": "optional", |
|
|
|
"data": { |
|
|
|
"title": "New proposal" |
|
|
|
"title": "New proposal", |
|
|
|
"message": "New transaction proposal created" |
|
|
|
} |
|
|
|
}; |
|
|
@ -129,30 +132,29 @@ PushNotificationsService.prototype.sendPushNotifications = function(notification |
|
|
|
opts.android = { |
|
|
|
"collapseKey": "optional", |
|
|
|
"data": { |
|
|
|
"title": "Rejected" |
|
|
|
"title": "Rejected", |
|
|
|
"message": "Transaction proposal finally rejected" |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
if (notification.type == ' TxProposalAcceptedBy') { |
|
|
|
if (notification.type == 'TxProposalAcceptedBy') { |
|
|
|
var opts = {}; |
|
|
|
opts.users = [notification.walletId]; |
|
|
|
opts.android = { |
|
|
|
"collapseKey": "optional", |
|
|
|
"data": { |
|
|
|
"title": "Accepted" |
|
|
|
"title": "Accepted", |
|
|
|
"message": "Transaction proposal accepted" |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
var url = 'http://192.168.1.126:8000/send'; |
|
|
|
var url = 'http://192.168.1.121:8000/send'; |
|
|
|
request({ |
|
|
|
url: url, |
|
|
|
method: 'POST', |
|
|
|
json: true, |
|
|
|
body: opts |
|
|
|
}, function(error, response, body) { |
|
|
|
console.log(error); |
|
|
|
console.log(response.statusCode); |
|
|
|
}); |
|
|
|
} |
|
|
|