The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/publications/subscription/index.js

34 lines
756 B

import { Meteor } from 'meteor/meteor';
import { Subscriptions } from '../../../app/models';
import { subscriptionFields } from '../../modules/watchers/watchers.module';
Meteor.methods({
'subscriptions/get'(updatedAt) {
if (!Meteor.userId()) {
return [];
}
const options = { fields: subscriptionFields };
const records = Subscriptions.findByUserId(Meteor.userId(), options).fetch();
if (updatedAt instanceof Date) {
return {
update: records.filter(function(record) {
return record._updatedAt > updatedAt;
}),
remove: Subscriptions.trashFindDeletedAfter(updatedAt, {
'u._id': Meteor.userId(),
}, {
fields: {
_id: 1,
_deletedAt: 1,
},
}).fetch(),
};
}
return records;
},
});