Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})
Expand Down
1 change: 1 addition & 0 deletions spec/PushController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({}));
Expand Down
2 changes: 0 additions & 2 deletions src/Adapters/Storage/Mongo/MongoTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you the _id case too?

transformedValue = transformAtom(restValue, false);
coercedToDate = typeof transformedValue === 'string' ? new Date(transformedValue) : transformedValue
Expand Down
17 changes: 9 additions & 8 deletions src/pushStatusHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(() => {
Expand All @@ -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,
};
Expand Down Expand Up @@ -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({
Expand Down