Encrypt subscription
This commit is contained in:
parent
7cc5511bc1
commit
eeb6647133
|
@ -349,6 +349,9 @@ class Encryption {
|
|||
}
|
||||
};
|
||||
|
||||
// Creating the instance is enough to generate room e2ee key
|
||||
encryptSubscription = (rid: string) => this.getRoomInstance(rid as string);
|
||||
|
||||
// Decrypt a subscription lastMessage
|
||||
decryptSubscription = async (subscription: Partial<ISubscription>) => {
|
||||
// If the subscription doesn't have a lastMessage just return
|
||||
|
|
|
@ -177,10 +177,14 @@ export default class EncryptionRoom {
|
|||
|
||||
// Create an encrypted key for this room based on users
|
||||
encryptRoomKey = async () => {
|
||||
const result = await Services.e2eGetUsersOfRoomWithoutKey(this.roomId);
|
||||
if (result.success) {
|
||||
const { users } = result;
|
||||
await Promise.all(users.map(user => this.encryptRoomKeyForUser(user)));
|
||||
try {
|
||||
const result = await Services.e2eGetUsersOfRoomWithoutKey(this.roomId);
|
||||
if (result.success) {
|
||||
const { users } = result;
|
||||
await Promise.all(users.map(user => this.encryptRoomKeyForUser(user)));
|
||||
}
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import I18n from '../i18n';
|
|||
import { events, logEvent } from '../lib/methods/helpers/log';
|
||||
import { goRoom } from '../lib/methods/helpers/goRoom';
|
||||
import { Services } from '../lib/services';
|
||||
import { Encryption } from '../lib/encryption';
|
||||
|
||||
const handleRequest = function* handleRequest({ data }) {
|
||||
try {
|
||||
|
@ -65,6 +66,10 @@ const handleRequest = function* handleRequest({ data }) {
|
|||
Object.assign(s, sub);
|
||||
});
|
||||
});
|
||||
|
||||
if (data.encrypted) {
|
||||
Encryption.encryptSubscription(sub.rid);
|
||||
}
|
||||
} catch {
|
||||
// do nothing
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue