@@ -24,18 +24,19 @@ export default function pushStatusHandler(config) {
24
24
let setInitial = function ( body = { } , where , options = { source : 'rest' } ) {
25
25
let now = new Date ( ) ;
26
26
let data = body . data || { } ;
27
+ let payloadString = JSON . stringify ( data ) ;
27
28
let object = {
28
- objectId,
29
+ _id : objectId ,
29
30
pushTime : now . toISOString ( ) ,
30
31
_created_at : now ,
31
32
query : JSON . stringify ( where ) ,
32
- payload : body . data ,
33
+ payload : payloadString ,
33
34
source : options . source ,
34
35
title : options . title ,
35
36
expiry : body . expiration_time ,
36
37
status : "pending" ,
37
38
numSent : 0 ,
38
- pushHash : md5Hash ( JSON . stringify ( data ) ) ,
39
+ pushHash : md5Hash ( payloadString ) ,
39
40
// lockdown!
40
41
_wperm : [ ] ,
41
42
_rperm : [ ]
@@ -44,7 +45,7 @@ export default function pushStatusHandler(config) {
44
45
return collection . insertOne ( object ) ;
45
46
} ) . then ( ( res ) => {
46
47
pushStatus = {
47
- objectId : object . objectId
48
+ objectId
48
49
} ;
49
50
return Promise . resolve ( pushStatus ) ;
50
51
} )
@@ -56,7 +57,7 @@ export default function pushStatusHandler(config) {
56
57
return initialPromise . then ( ( ) => {
57
58
return collection ( ) ;
58
59
} ) . 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" } } ) ;
60
61
} ) ;
61
62
}
62
63
@@ -93,7 +94,7 @@ export default function pushStatusHandler(config) {
93
94
return initialPromise . then ( ( ) => {
94
95
return collection ( ) ;
95
96
} ) . then ( ( collection ) => {
96
- return collection . updateOne ( { status :"running" , objectId : pushStatus . objectId } , { $set : update } ) ;
97
+ return collection . updateOne ( { status :"running" , _id : objectId } , { $set : update } ) ;
97
98
} ) ;
98
99
}
99
100
@@ -106,7 +107,7 @@ export default function pushStatusHandler(config) {
106
107
return initialPromise . then ( ( ) => {
107
108
return collection ( ) ;
108
109
} ) . then ( ( collection ) => {
109
- return collection . updateOne ( { objectId : pushStatus . objectId } , { $set : update } ) ;
110
+ return collection . updateOne ( { _id : objectId } , { $set : update } ) ;
110
111
} ) ;
111
112
}
112
113
0 commit comments