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

72 lines
1.2 KiB

import { Meteor } from 'meteor/meteor';
import { Subscriptions } from '../../../app/models';
import './emitter';
export const fields = {
t: 1,
ts: 1,
ls: 1,
name: 1,
fname: 1,
rid: 1,
code: 1,
f: 1,
u: 1,
open: 1,
alert: 1,
roles: 1,
unread: 1,
prid: 1,
userMentions: 1,
groupMentions: 1,
archived: 1,
audioNotifications: 1,
audioNotificationValue: 1,
desktopNotifications: 1,
desktopNotificationDuration: 1,
mobilePushNotifications: 1,
emailNotifications: 1,
unreadAlert: 1,
_updatedAt: 1,
blocked: 1,
blocker: 1,
autoTranslate: 1,
autoTranslateLanguage: 1,
disableNotifications: 1,
hideUnreadStatus: 1,
muteGroupMentions: 1,
ignored: 1,
E2EKey: 1,
tunread: 1,
};
Meteor.methods({
'subscriptions/get'(updatedAt) {
if (!Meteor.userId()) {
return [];
}
const options = { fields };
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;
},
});