Skip to content

Commit 97d08d4

Browse files
authored
feat: Add support for reset MLS conversation event [WPB-17706] (#19407)
* feat: Add support for reset MLS conversation event [WPB-17706] * bump core
1 parent 9835950 commit 97d08d4

File tree

3 files changed

+55
-19
lines changed

3 files changed

+55
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@wireapp/avs": "10.0.46",
1717
"@wireapp/avs-debugger": "0.0.7",
1818
"@wireapp/commons": "5.4.3",
19-
"@wireapp/core": "46.33.0",
19+
"@wireapp/core": "46.34.0",
2020
"@wireapp/kalium-backup": "0.0.4",
2121
"@wireapp/react-ui-kit": "9.63.0",
2222
"@wireapp/store-engine-dexie": "2.1.15",

src/script/repositories/conversation/ConversationRepository.ts

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
CONVERSATION_EVENT,
4747
ConversationProtocolUpdateEvent,
4848
ConversationAddPermissionUpdateEvent,
49+
ConversationMLSResetEvent,
4950
} from '@wireapp/api-client/lib/event';
5051
import {BackendErrorLabel} from '@wireapp/api-client/lib/http/';
5152
import type {BackendError} from '@wireapp/api-client/lib/http/';
@@ -1110,9 +1111,15 @@ export class ConversationRepository {
11101111
return this.updateConversations(this.conversationState.archivedConversations());
11111112
}
11121113

1113-
private async updateConversationFromBackend(conversationEntity: Conversation) {
1114+
private async updateConversationFromBackend(conversationEntity: Conversation): Promise<void> {
11141115
const conversationData = await this.conversationService.getConversationById(conversationEntity);
1115-
const {name, message_timer, type} = conversationData;
1116+
const {name, message_timer, type, group_id: groupId, epoch} = conversationData;
1117+
1118+
if (groupId && typeof epoch === 'number') {
1119+
ConversationMapper.updateProperties(conversationEntity, {groupId, epoch});
1120+
}
1121+
1122+
ConversationMapper.updateProperties(conversationEntity, {name, type});
11161123
ConversationMapper.updateProperties(conversationEntity, {name, type});
11171124
ConversationMapper.updateSelfStatus(conversationEntity, {message_timer});
11181125
}
@@ -2791,9 +2798,9 @@ export class ConversationRepository {
27912798
* @returns Resolves with updated conversation entity
27922799
*/
27932800
private async refreshConversationProtocolProperties(conversation: Conversation) {
2794-
//refetch the conversation to get all new fields (groupId, ciphersuite, epoch and new protocol)
2801+
// refetch the conversation to get all new fields (groupId, ciphersuite, epoch and new protocol)
27952802
const remoteConversationData = await this.conversationService.getConversationById(conversation.qualifiedId);
2796-
//update fields that came after protocol update
2803+
// update fields that came after protocol update
27972804
const {cipher_suite: cipherSuite, epoch, group_id: newGroupId, protocol: newProtocol} = remoteConversationData;
27982805
const updatedConversation = ConversationMapper.updateProperties(conversation, {
27992806
cipherSuite,
@@ -3192,7 +3199,11 @@ export class ConversationRepository {
31923199

31933200
const inSelfConversation = this.conversationState.isSelfConversation(conversationId);
31943201
if (inSelfConversation) {
3195-
const typesInSelfConversation = [CONVERSATION_EVENT.MEMBER_UPDATE, ClientEvent.CONVERSATION.MESSAGE_HIDDEN];
3202+
const typesInSelfConversation = [
3203+
CONVERSATION_EVENT.MEMBER_UPDATE,
3204+
CONVERSATION_EVENT.MLS_RESET,
3205+
ClientEvent.CONVERSATION.MESSAGE_HIDDEN,
3206+
];
31963207

31973208
const isExpectedType = typesInSelfConversation.includes(type);
31983209
if (!isExpectedType) {
@@ -3406,6 +3417,9 @@ export class ConversationRepository {
34063417
case CONVERSATION_EVENT.MLS_WELCOME_MESSAGE:
34073418
return this.onMLSWelcomeMessage(conversationEntity);
34083419

3420+
case CONVERSATION_EVENT.MLS_RESET:
3421+
return this.onMLSResetMessage(conversationEntity, eventJson);
3422+
34093423
case ClientEvent.CONVERSATION.ASSET_ADD:
34103424
return this.onAssetAdd(conversationEntity, eventJson);
34113425

@@ -4101,6 +4115,28 @@ export class ConversationRepository {
41014115
await this.resolve1To1Conversation(otherUserId);
41024116
}
41034117

4118+
/**
4119+
* A user has reset an MLS Conversation.
4120+
* This means group id and epoch have changed, so we need to
4121+
* update the conversation to the latest group id and epoch.
4122+
*
4123+
* @param conversationEntity Conversation entity user has received a welcome message in
4124+
* @returns Resolves when the event was handled
4125+
*/
4126+
private async onMLSResetMessage(conversationEntity: Conversation, eventJson: ConversationMLSResetEvent) {
4127+
try {
4128+
if (!isMLSConversation(conversationEntity)) {
4129+
return;
4130+
}
4131+
4132+
await this.core.service?.conversation.wipeMLSConversation(eventJson.data.group_id);
4133+
4134+
await this.refreshConversationProtocolProperties(conversationEntity);
4135+
} catch (error) {
4136+
this.logger.error(`Failed to reset MLS conversation ${conversationEntity.id}`, error);
4137+
}
4138+
}
4139+
41044140
/**
41054141
* A user started or stopped typing in a conversation.
41064142
*

yarn.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8094,9 +8094,9 @@ __metadata:
80948094
languageName: node
80958095
linkType: hard
80968096

8097-
"@wireapp/api-client@npm:^27.74.0":
8098-
version: 27.74.0
8099-
resolution: "@wireapp/api-client@npm:27.74.0"
8097+
"@wireapp/api-client@npm:^27.75.0":
8098+
version: 27.75.0
8099+
resolution: "@wireapp/api-client@npm:27.75.0"
81008100
dependencies:
81018101
"@aws-sdk/client-s3": "npm:3.864.0"
81028102
"@aws-sdk/lib-storage": "npm:3.864.0"
@@ -8115,7 +8115,7 @@ __metadata:
81158115
uuid: "npm:11.1.0"
81168116
ws: "npm:8.18.1"
81178117
zod: "npm:3.24.2"
8118-
checksum: 10/e257ac14c6bd575f2cb9699ccdaace2583e4dbb63dd5f2219375d449fe69f69bcc75c38bb76a1e99e488006db452b2b76840b3075402ad9eb3ec2d344b07d23c
8118+
checksum: 10/d1c44e63897e00318d9cc7c5adef0c1a2c7ccdcc9b158a4cb8b9d99c1d6978ddfcb7226379e9cdb9037d091217edb07770421f791cf442060de98194a45274d3
81198119
languageName: node
81208120
linkType: hard
81218121

@@ -8192,11 +8192,11 @@ __metadata:
81928192
languageName: node
81938193
linkType: hard
81948194

8195-
"@wireapp/core@npm:46.33.0":
8196-
version: 46.33.0
8197-
resolution: "@wireapp/core@npm:46.33.0"
8195+
"@wireapp/core@npm:46.34.0":
8196+
version: 46.34.0
8197+
resolution: "@wireapp/core@npm:46.34.0"
81988198
dependencies:
8199-
"@wireapp/api-client": "npm:^27.74.0"
8199+
"@wireapp/api-client": "npm:^27.75.0"
82008200
"@wireapp/commons": "npm:^5.4.4"
82018201
"@wireapp/core-crypto": "npm:7.0.2"
82028202
"@wireapp/cryptobox": "npm:12.8.0"
@@ -8214,7 +8214,7 @@ __metadata:
82148214
long: "npm:^5.2.0"
82158215
uuid: "npm:9.0.1"
82168216
zod: "npm:3.24.2"
8217-
checksum: 10/ed49aee978368d8981ed623c0ffb92035d5e0eb3fd567fd800976cfab6576980817acd47caefed1b708b5a77935339a4aa104500a9aafac45f9058d6afd16079
8217+
checksum: 10/4b66657311c6f69f100f9ece61cca9c95be8efeaf6ffa68e17d1221e0904fd1dbd769d218ae7c320f4338a9f2dea98e279fe49e2ee8260e6bbf8c2436f3fd548
82188218
languageName: node
82198219
linkType: hard
82208220

@@ -9424,12 +9424,12 @@ __metadata:
94249424
linkType: hard
94259425

94269426
"brace-expansion@npm:^1.1.7":
9427-
version: 1.1.12
9428-
resolution: "brace-expansion@npm:1.1.12"
9427+
version: 1.1.11
9428+
resolution: "brace-expansion@npm:1.1.11"
94299429
dependencies:
94309430
balanced-match: "npm:^1.0.0"
94319431
concat-map: "npm:0.0.1"
9432-
checksum: 10/12cb6d6310629e3048cadb003e1aca4d8c9bb5c67c3c321bafdd7e7a50155de081f78ea3e0ed92ecc75a9015e784f301efc8132383132f4f7904ad1ac529c562
9432+
checksum: 10/faf34a7bb0c3fcf4b59c7808bc5d2a96a40988addf2e7e09dfbb67a2251800e0d14cd2bfc1aa79174f2f5095c54ff27f46fb1289fe2d77dac755b5eb3434cc07
94339433
languageName: node
94349434
linkType: hard
94359435

@@ -21879,7 +21879,7 @@ __metadata:
2187921879
"@wireapp/avs-debugger": "npm:0.0.7"
2188021880
"@wireapp/commons": "npm:5.4.3"
2188121881
"@wireapp/copy-config": "npm:2.3.1"
21882-
"@wireapp/core": "npm:46.33.0"
21882+
"@wireapp/core": "npm:46.34.0"
2188321883
"@wireapp/eslint-config": "npm:3.0.7"
2188421884
"@wireapp/kalium-backup": "npm:0.0.4"
2188521885
"@wireapp/prettier-config": "npm:0.6.4"

0 commit comments

Comments
 (0)