Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion spec/PushController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,11 @@ describe('PushController', () => {
expect(results.length).toBe(1);
let result = results[0];
expect(result.createdAt instanceof Date).toBe(true);
expect(result.id.length).toBe(10);
expect(result.get('source')).toEqual('rest');
expect(result.get('query')).toEqual(JSON.stringify({}));
expect(result.get('payload')).toEqual(payload.data);
expect(typeof result.get('payload')).toEqual("string");
expect(JSON.parse(result.get('payload'))).toEqual(payload.data);
expect(result.get('status')).toEqual('succeeded');
expect(result.get('numSent')).toEqual(10);
expect(result.get('sentPerType')).toEqual({
Expand Down
15 changes: 8 additions & 7 deletions src/pushStatusHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,19 @@ export default function pushStatusHandler(config) {
let setInitial = function(body = {}, where, options = {source: 'rest'}) {
let now = new Date();
let data = body.data || {};
let payloadString = JSON.stringify(data);
let object = {
objectId,
_id: objectId,
pushTime: now.toISOString(),
_created_at: now,
query: JSON.stringify(where),
payload: body.data,
payload: payloadString,
source: options.source,
title: options.title,
expiry: body.expiration_time,
status: "pending",
numSent: 0,
pushHash: md5Hash(JSON.stringify(data)),
pushHash: md5Hash(payloadString),
// lockdown!
_wperm: [],
_rperm: []
Expand All @@ -44,7 +45,7 @@ export default function pushStatusHandler(config) {
return collection.insertOne(object);
}).then((res) => {
pushStatus = {
objectId: object.objectId
objectId
};
return Promise.resolve(pushStatus);
})
Expand All @@ -56,7 +57,7 @@ export default function pushStatusHandler(config) {
return initialPromise.then(() => {
return collection();
}).then((collection) => {
return collection.updateOne({status:"pending", objectId: pushStatus.objectId}, {$set: {status: "running"}});
return collection.updateOne({status:"pending", _id: objectId}, {$set: {status: "running"}});
});
}

Expand Down Expand Up @@ -93,7 +94,7 @@ export default function pushStatusHandler(config) {
return initialPromise.then(() => {
return collection();
}).then((collection) => {
return collection.updateOne({status:"running", objectId: pushStatus.objectId}, {$set: update});
return collection.updateOne({status:"running", _id: objectId}, {$set: update});
});
}

Expand All @@ -106,7 +107,7 @@ export default function pushStatusHandler(config) {
return initialPromise.then(() => {
return collection();
}).then((collection) => {
return collection.updateOne({objectId: pushStatus.objectId}, {$set: update});
return collection.updateOne({_id: objectId}, {$set: update});
});
}

Expand Down