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/app/models/server/raw/Subscriptions.js

57 lines
882 B

import { BaseRaw } from './BaseRaw';
export class SubscriptionsRaw extends BaseRaw {
findOneByRoomIdAndUserId(rid, uid, options) {
const query = {
rid,
'u._id': uid,
};
return this.col.findOne(query, options);
}
countByRoomIdAndUserId(rid, uid) {
const query = {
rid,
'u._id': uid,
};
const cursor = this.col.find(query);
return cursor.count();
}
isUserInRole(uid, roleName, rid) {
if (rid == null) {
return;
}
const query = {
'u._id': uid,
rid,
roles: roleName,
};
return this.findOne(query, { fields: { roles: 1 } });
}
setAsReadByRoomIdAndUserId(rid, uid, alert = false) {
const query = {
rid,
'u._id': uid,
};
const update = {
$set: {
open: true,
alert,
unread: 0,
userMentions: 0,
groupMentions: 0,
ls: new Date(),
},
};
return this.col.update(query, update);
}
}