diff --git a/spec/ParseAPI.spec.js b/spec/ParseAPI.spec.js index 73ab223bfb..b3c26b028d 100644 --- a/spec/ParseAPI.spec.js +++ b/spec/ParseAPI.spec.js @@ -1340,7 +1340,6 @@ describe('miscellaneous', function() { expect(res.key).toBe(1); return runIncrement(-1); }).then((res) => { - console.log(res); expect(res.key).toBe(0); done(); }) diff --git a/spec/PushController.spec.js b/spec/PushController.spec.js index fbb4124491..7e2ed3a231 100644 --- a/spec/PushController.spec.js +++ b/spec/PushController.spec.js @@ -293,6 +293,7 @@ describe('PushController', () => { expect(results.length).toBe(1); let result = results[0]; expect(result.createdAt instanceof Date).toBe(true); + expect(result.updatedAt instanceof Date).toBe(true); expect(result.id.length).toBe(10); expect(result.get('source')).toEqual('rest'); expect(result.get('query')).toEqual(JSON.stringify({})); diff --git a/src/Adapters/Storage/Mongo/MongoTransform.js b/src/Adapters/Storage/Mongo/MongoTransform.js index 10ad188463..9cac0659b5 100644 --- a/src/Adapters/Storage/Mongo/MongoTransform.js +++ b/src/Adapters/Storage/Mongo/MongoTransform.js @@ -214,8 +214,6 @@ const parseObjectKeyValueToMongoObjectKeyValue = ( let coercedToDate; switch(restKey) { case 'objectId': return {key: '_id', value: restValue}; - case '_created_at'://TODO: for some reason, _PushStatus is already transformed when it gets here. For now, - // just pass the _created_at through. Later, we should make sure the push status doesn't get transformed inside Parse Server. case 'createdAt': transformedValue = transformAtom(restValue, false); coercedToDate = typeof transformedValue === 'string' ? new Date(transformedValue) : transformedValue @@ -228,8 +226,6 @@ const parseObjectKeyValueToMongoObjectKeyValue = ( transformedValue = transformAtom(restValue, false); coercedToDate = typeof transformedValue === 'string' ? new Date(transformedValue) : transformedValue return {key: 'expiresAt', value: coercedToDate}; - case '_id': //TODO: for some reason, _PushStatus is already transformed when it gets here. For now, - // just pass the ID through. Later, we should make sure the push status doesn't get transformed inside Parse Server. case '_rperm': case '_wperm': case '_email_verify_token': diff --git a/src/pushStatusHandler.js b/src/pushStatusHandler.js index 7b60ff7187..dfe887f3ea 100644 --- a/src/pushStatusHandler.js +++ b/src/pushStatusHandler.js @@ -26,9 +26,9 @@ export default function pushStatusHandler(config) { let data = body.data || {}; let payloadString = JSON.stringify(data); let object = { - _id: objectId, + objectId, + createdAt: now, pushTime: now.toISOString(), - _created_at: now, query: JSON.stringify(where), payload: payloadString, source: options.source, @@ -38,8 +38,7 @@ export default function pushStatusHandler(config) { numSent: 0, pushHash: md5Hash(payloadString), // lockdown! - _wperm: [], - _rperm: [] + ACL: {} } return database.create(PUSH_STATUS_COLLECTION, object).then(() => { @@ -54,12 +53,13 @@ export default function pushStatusHandler(config) { logger.verbose('sending push to %d installations', installations.length); return database.update(PUSH_STATUS_COLLECTION, {status:"pending", objectId: objectId}, - {status: "running"}); + {status: "running", updatedAt: new Date() }); } let complete = function(results) { let update = { status: 'succeeded', + updatedAt: new Date(), numSent: 0, numFailed: 0, }; @@ -87,16 +87,17 @@ export default function pushStatusHandler(config) { }, update); } logger.verbose('sent push! %d success, %d failures', update.numSent, update.numFailed); - return database.update('_PushStatus', {status:"running", objectId }, update); + return database.update(PUSH_STATUS_COLLECTION, {status:"running", objectId }, update); } let fail = function(err) { let update = { errorMessage: JSON.stringify(err), - status: 'failed' + status: 'failed', + updatedAt: new Date() } logger.error('error while sending push', err); - return database.update('_PushStatus', { objectId }, update); + return database.update(PUSH_STATUS_COLLECTION, { objectId }, update); } return Object.freeze({