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/packages/rocketchat-lib/server/startup/cache/CacheLoad.js

51 lines
1.1 KiB

RocketChat.models.Rooms.cache.hasMany('Subscriptions', {
field: 'usernames',
link: {
local: '_id',
remote: 'rid',
transform(room, subscription) {
return subscription.u.username;
},
remove(arr, subscription) {
if (arr.indexOf(subscription.u.username) > -1) {
arr.splice(arr.indexOf(subscription.u.username), 1);
}
}
}
});
RocketChat.models.Subscriptions.cache.hasOne('Rooms', {
field: '_room',
link: {
local: 'rid',
remote: '_id'
}
});
RocketChat.models.Subscriptions.cache.hasOne('Users', {
field: '_user',
link: {
local: 'u._id',
remote: '_id'
}
});
RocketChat.models.Users.cache.load();
RocketChat.models.Rooms.cache.load();
RocketChat.models.Subscriptions.cache.load();
RocketChat.models.Settings.cache.load();
RocketChat.models.Users.cache.addDynamicView('highlights').applyFind({
'settings.preferences.highlights': {$size: {$gt: 0}}
});
RocketChat.models.Subscriptions.cache.addDynamicView('notifications').applyFind({
$or: [
{desktopNotifications: {$in: ['all', 'nothing']}},
{mobilePushNotifications: {$in: ['all', 'nothing']}}
]
});