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/channel-settings/server/functions/saveRoomEncrypted.ts

26 lines
800 B

import { Meteor } from 'meteor/meteor';
import { Match } from 'meteor/check';
import type { WriteOpResult } from 'mongodb';
import { Rooms, Messages } from '../../../models/server';
import type { IUser } from '../../../../definition/IUser';
export const saveRoomEncrypted = function (rid: string, encrypted: boolean, user: IUser, sendMessage = true): Promise<WriteOpResult> {
if (!Match.test(rid, String)) {
throw new Meteor.Error('invalid-room', 'Invalid room', {
function: 'RocketChat.saveRoomEncrypted',
});
}
const update = Rooms.saveEncryptedById(rid, encrypted);
if (update && sendMessage) {
Messages.createRoomSettingsChangedWithTypeRoomIdMessageAndUser(
`room_e2e_${encrypted ? 'enabled' : 'disabled'}`,
rid,
user.username,
user,
{},
);
}
return update;
};