diff --git a/test/api/v3/unit/middlewares/response.js b/test/api/v3/unit/middlewares/response.js index cbf2f178e3..302f5b8f97 100644 --- a/test/api/v3/unit/middlewares/response.js +++ b/test/api/v3/unit/middlewares/response.js @@ -98,7 +98,6 @@ describe('response middleware', () => { { type: notification.type, id: notification.id, - createdAt: notification.createdAt, data: {}, }, ], diff --git a/test/api/v3/unit/models/user.test.js b/test/api/v3/unit/models/user.test.js index 861f8e0016..f9651c9224 100644 --- a/test/api/v3/unit/models/user.test.js +++ b/test/api/v3/unit/models/user.test.js @@ -55,7 +55,7 @@ describe('User Model', () => { let userToJSON = user.toJSON(); expect(user.notifications.length).to.equal(1); - expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'createdAt']); + expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']); expect(userToJSON.notifications[0].type).to.equal('CRON'); expect(userToJSON.notifications[0].data).to.eql({}); }); @@ -67,7 +67,7 @@ describe('User Model', () => { let userToJSON = user.toJSON(); expect(user.notifications.length).to.equal(1); - expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type', 'createdAt']); + expect(userToJSON.notifications[0]).to.have.all.keys(['data', 'id', 'type']); expect(userToJSON.notifications[0].type).to.equal('CRON'); expect(userToJSON.notifications[0].data).to.eql({field: 1}); }); diff --git a/website/server/libs/cron.js b/website/server/libs/cron.js index 367356922b..fb99b88290 100644 --- a/website/server/libs/cron.js +++ b/website/server/libs/cron.js @@ -134,7 +134,7 @@ function awardLoginIncentives (user) { // Remove old notifications if they exists user.notifications .toObject() - .find((notif, index) => { + .forEach((notif, index) => { if (notif.type === 'LOGIN_INCENTIVE') user.notifications.splice(index, 1); }); diff --git a/website/server/models/userNotification.js b/website/server/models/userNotification.js index dae5e70769..06dd959b95 100644 --- a/website/server/models/userNotification.js +++ b/website/server/models/userNotification.js @@ -38,8 +38,7 @@ export let schema = new Schema({ schema.plugin(baseModel, { noSet: ['_id', 'id'], - timestamps: true, - private: ['updatedAt'], + // timestamps: true, // Temporarily removed to debug a possible bug _id: false, // use id instead of _id });