@@ -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 = {
28- objectId,
29+ _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 : [ ]
@@ -44,7 +45,7 @@ export default function pushStatusHandler(config) {
4445 return collection . insertOne ( object ) ;
4546 } ) . then ( ( res ) => {
4647 pushStatus = {
47- objectId : object . objectId
48+ objectId
4849 } ;
4950 return Promise . resolve ( pushStatus ) ;
5051 } )
@@ -56,7 +57,7 @@ export default function pushStatusHandler(config) {
5657 return initialPromise . then ( ( ) => {
5758 return collection ( ) ;
5859 } ) . then ( ( collection ) => {
59- return collection . updateOne ( { status :"pending" , objectId : pushStatus . objectId } , { $set : { status : "running" } } ) ;
60+ return collection . updateOne ( { status :"pending" , _id : objectId } , { $set : { status : "running" } } ) ;
6061 } ) ;
6162 }
6263
@@ -93,7 +94,7 @@ export default function pushStatusHandler(config) {
9394 return initialPromise . then ( ( ) => {
9495 return collection ( ) ;
9596 } ) . then ( ( collection ) => {
96- return collection . updateOne ( { status :"running" , objectId : pushStatus . objectId } , { $set : update } ) ;
97+ return collection . updateOne ( { status :"running" , _id : objectId } , { $set : update } ) ;
9798 } ) ;
9899 }
99100
@@ -106,7 +107,7 @@ export default function pushStatusHandler(config) {
106107 return initialPromise . then ( ( ) => {
107108 return collection ( ) ;
108109 } ) . then ( ( collection ) => {
109- return collection . updateOne ( { objectId : pushStatus . objectId } , { $set : update } ) ;
110+ return collection . updateOne ( { _id : objectId } , { $set : update } ) ;
110111 } ) ;
111112 }
112113
0 commit comments