Notifications: remove timestamps (#8287)

* user notifications: make updatedAt public

* notifications: disable timestamps
This commit is contained in:
Matteo Pagliazzi
2016-12-15 17:33:24 +01:00
committed by GitHub
parent fa788f49fc
commit 237095d109
4 changed files with 4 additions and 6 deletions

View File

@@ -98,7 +98,6 @@ describe('response middleware', () => {
{ {
type: notification.type, type: notification.type,
id: notification.id, id: notification.id,
createdAt: notification.createdAt,
data: {}, data: {},
}, },
], ],

View File

@@ -55,7 +55,7 @@ describe('User Model', () => {
let userToJSON = user.toJSON(); let userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1); 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].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({}); expect(userToJSON.notifications[0].data).to.eql({});
}); });
@@ -67,7 +67,7 @@ describe('User Model', () => {
let userToJSON = user.toJSON(); let userToJSON = user.toJSON();
expect(user.notifications.length).to.equal(1); 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].type).to.equal('CRON');
expect(userToJSON.notifications[0].data).to.eql({field: 1}); expect(userToJSON.notifications[0].data).to.eql({field: 1});
}); });

View File

@@ -134,7 +134,7 @@ function awardLoginIncentives (user) {
// Remove old notifications if they exists // Remove old notifications if they exists
user.notifications user.notifications
.toObject() .toObject()
.find((notif, index) => { .forEach((notif, index) => {
if (notif.type === 'LOGIN_INCENTIVE') user.notifications.splice(index, 1); if (notif.type === 'LOGIN_INCENTIVE') user.notifications.splice(index, 1);
}); });

View File

@@ -38,8 +38,7 @@ export let schema = new Schema({
schema.plugin(baseModel, { schema.plugin(baseModel, {
noSet: ['_id', 'id'], noSet: ['_id', 'id'],
timestamps: true, // timestamps: true, // Temporarily removed to debug a possible bug
private: ['updatedAt'],
_id: false, // use id instead of _id _id: false, // use id instead of _id
}); });