todos-contra-el-fuego-web/imports/api/Notifications/methods.js
Vicente J. Ruiz Jurado bf926514c9 Mobile notifications
2018-08-02 12:42:19 +02:00

25 lines
605 B
JavaScript

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import Notifications from './Notifications';
import rateLimit from '../../modules/rate-limit';
Meteor.methods({
'notifications.sent': function notificationsUpdate(notifId) {
check(notifId, Meteor.Collection.ObjectID);
try {
Notifications.update(notifId, { $set: { notified: true, notifiedAt: new Date() } });
return notifId;
} catch (exception) {
throw new Meteor.Error('500', exception);
}
}
});
rateLimit({
methods: [
'notifications.sent'
],
limit: 5,
timeRange: 1000
});