Change pushHash with stringified data (#2397)

* Change pushHash with stringify data

* stringify data.alert for pushHash

* stringify data.alert if object for pushHash

* test push notification when data.alert is an object
This commit is contained in:
Antoine Lenoir
2016-08-09 18:00:56 +02:00
committed by Florent Vilmart
parent e6d31a07ab
commit 452887bd05
2 changed files with 50 additions and 1 deletions

View File

@@ -25,6 +25,14 @@ export default function pushStatusHandler(config) {
let now = new Date();
let data = body.data || {};
let payloadString = JSON.stringify(data);
let pushHash;
if (typeof data.alert === 'string') {
pushHash = md5Hash(data.alert);
} else if (typeof data.alert === 'object') {
pushHash = md5Hash(JSON.stringify(data.alert));
} else {
pushHash = 'd41d8cd98f00b204e9800998ecf8427e';
}
let object = {
objectId,
createdAt: now,
@@ -36,7 +44,7 @@ export default function pushStatusHandler(config) {
expiry: body.expiration_time,
status: "pending",
numSent: 0,
pushHash: md5Hash(data.alert || ''),
pushHash,
// lockdown!
ACL: {}
}