Skip to content

Commit 0bc4832

Browse files
committed
_PushStatus stores serialized payload (fixes #1458)
1 parent b11f3cb commit 0bc4832

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

spec/PushController.spec.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ describe('PushController', () => {
298298
expect(result.id.length).toBe(10);
299299
expect(result.get('source')).toEqual('rest');
300300
expect(result.get('query')).toEqual(JSON.stringify({}));
301-
expect(result.get('payload')).toEqual(payload.data);
301+
expect(typeof result.get('payload')).toEqual("string");
302+
expect(JSON.parse(result.get('payload'))).toEqual(payload.data);
302303
expect(result.get('status')).toEqual('succeeded');
303304
expect(result.get('numSent')).toEqual(10);
304305
expect(result.get('sentPerType')).toEqual({

src/pushStatusHandler.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,19 @@ export default function pushStatusHandler(config) {
2424
let setInitial = function(body = {}, where, options = {source: 'rest'}) {
2525
let now = new Date();
2626
let data = body.data || {};
27+
let payloadString = JSON.stringify(data);
2728
let object = {
2829
_id: objectId,
2930
pushTime: now.toISOString(),
3031
_created_at: now,
3132
query: JSON.stringify(where),
32-
payload: body.data,
33+
payload: payloadString,
3334
source: options.source,
3435
title: options.title,
3536
expiry: body.expiration_time,
3637
status: "pending",
3738
numSent: 0,
38-
pushHash: md5Hash(JSON.stringify(data)),
39+
pushHash: md5Hash(payloadString),
3940
// lockdown!
4041
_wperm: [],
4142
_rperm: []

0 commit comments

Comments
 (0)