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-e2e/server/models/Users.js

36 lines
782 B

import { RocketChat } from 'meteor/rocketchat:lib';
RocketChat.models.Users.setE2EPublicAndPivateKeysByUserId = function(userId, { public_key, private_key }) {
this.update({ _id: userId }, {
$set: {
'e2e.public_key': public_key,
'e2e.private_key': private_key,
},
});
};
RocketChat.models.Users.fetchKeysByUserId = function(userId) {
const user = this.findOne({ _id: userId }, { fields: { e2e: 1 } });
if (!user || !user.e2e || !user.e2e.public_key) {
return {};
}
return {
public_key: user.e2e.public_key,
private_key: user.e2e.private_key,
};
};
RocketChat.models.Users.findByIdsWithPublicE2EKey = function(ids, options) {
const query = {
_id: {
$in: ids,
},
'e2e.public_key': {
$exists: 1,
},
};
return this.find(query, options);
};