cartodb-4.42/lib/assets/javascripts/dashboard/components/dashboard-header/notifications/organization-notification-model.js
2024-04-06 05:25:13 +00:00

31 lines
631 B
JavaScript

const UserNotificationModel = require('./user-notification-model');
const checkAndBuildOpts = require('builder/helpers/required-opts');
const REQUIRED_OPTS = [
'userId',
'configModel',
'apiKey'
];
/**
* User notification default model
*/
module.exports = UserNotificationModel.extend({
url: function () {
return `/api/v3/users/${this._userId}/notifications/${this.id}?api_key=${this._apiKey}`;
},
initialize: function (attrs, opts) {
checkAndBuildOpts(opts, REQUIRED_OPTS, this);
},
markAsRead: function () {
this.save({
notification: {
read_at: new Date()
}
});
}
});