Skip to content

Commit 3c32168

Browse files
committed
chore: Revert "fix: handle user.delete event [WPB-18869] (#19424)"
This reverts commit cb049ec.
1 parent cb049ec commit 3c32168

File tree

8 files changed

+4
-66
lines changed

8 files changed

+4
-66
lines changed

src/i18n/de-DE.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@
548548
"conversationLikesCaptionSingular": "[bold]{userName}[/bold]",
549549
"conversationLocationLink": "Standort anzeigen",
550550
"conversationMLSMigrationFinalisationOngoingCall": "Aufgrund der Umstellung auf MLS haben Sie möglicherweise Probleme mit Ihrem aktuellen Anruf. Wenn das der Fall ist, legen Sie auf und rufen Sie erneut an.",
551-
"conversationMemberDeleted": "Dieser Benutzer ist nicht mehr verfügbar",
552551
"conversationMemberJoined": "[bold]{name}[/bold] hat {users} hinzugefügt",
553552
"conversationMemberJoinedMore": "[bold]{name}[/bold] hat {users} und [showmore]{count} andere[/showmore] hinzugefügt",
554553
"conversationMemberJoinedSelf": "[bold]{name}[/bold] ist beigetreten",

src/i18n/en-US.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@
551551
"conversationLikesCaptionSingular": "[bold]{userName}[/bold]",
552552
"conversationLocationLink": "Open Map",
553553
"conversationMLSMigrationFinalisationOngoingCall": "Due to migration to MLS, you might have issues with your current call. If that's the case, hang up and call again.",
554-
"conversationMemberDeleted": "This user is no longer available",
555554
"conversationMemberJoined": "[bold]{name}[/bold] added {users} to the conversation",
556555
"conversationMemberJoinedMore": "[bold]{name}[/bold] added {users}, and [showmore]{count} more[/showmore] to the conversation",
557556
"conversationMemberJoinedSelf": "[bold]{name}[/bold] joined",

src/script/components/MessagesList/Message/MemberMessage/MessageContent.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,6 @@ function getContent(message: MemberMessageEntity) {
184184
if (!actor.id) {
185185
return t('conversationMemberWereRemoved', {users: allUsers}, {}, true);
186186
}
187-
188-
if (message.reason === MemberLeaveReason.USER_DELETED) {
189-
return t('conversationMemberDeleted');
190-
}
191-
192187
return actor.isMe
193188
? t('conversationMemberRemovedYou', {users: allUsers}, {}, true)
194189
: t('conversationMemberRemoved', {name, users: allUsers}, {}, true);

src/script/conversation/ConversationRepository.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ export class ConversationRepository {
383383

384384
this.selfRepository.on('selfSupportedProtocolsUpdated', this.initAllLocal1To1Conversations);
385385
this.userRepository.on('supportedProtocolsUpdated', this.onUserSupportedProtocolsUpdated);
386-
this.userRepository.on('userDeleted', this.onUserDeleted);
387386
}
388387

389388
public initMLSConversationRecoveredListener() {
@@ -2440,29 +2439,6 @@ export class ConversationRepository {
24402439
return this.eventRepository.injectEvent(event, EventRepository.SOURCE.INJECTED);
24412440
}
24422441

2443-
/**
2444-
* Will inject a member deleted event in 1:1 conversations with that user.
2445-
* This will be used to notify the other user that the user was deleted.
2446-
*
2447-
* @param userId User ID of the user that was deleted
2448-
*/
2449-
2450-
private readonly onUserDeleted = async (userId: QualifiedId) => {
2451-
const found1to1Conversation = this.conversationState.get1to1ConversationWithUser(userId);
2452-
if (!found1to1Conversation) {
2453-
return;
2454-
}
2455-
2456-
const deletedEvent = EventBuilder.buildMemberLeave(
2457-
found1to1Conversation,
2458-
[userId],
2459-
'',
2460-
this.serverTimeHandler.toServerTimestamp(),
2461-
MemberLeaveReason.USER_DELETED,
2462-
);
2463-
await this.eventRepository.injectEvent(deletedEvent, EventRepository.SOURCE.INJECTED);
2464-
};
2465-
24662442
/**
24672443
* Add service to conversation.
24682444
*

src/script/conversation/ConversationState.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -227,23 +227,6 @@ export class ConversationState {
227227
return mlsConversation || null;
228228
}
229229

230-
/**
231-
* Get a 1:1 conversation with a user.
232-
* @param userId User ID
233-
* @returns Conversation with the user or undefined if not found
234-
*/
235-
get1to1ConversationWithUser(userId: QualifiedId): Conversation | undefined {
236-
const foundMLSConversation = this.findMLS1to1Conversation(userId);
237-
if (foundMLSConversation) {
238-
return foundMLSConversation;
239-
}
240-
const foundProteusConversations = this.findProteus1to1Conversations(userId);
241-
if (foundProteusConversations && foundProteusConversations.length > 0) {
242-
return foundProteusConversations[0];
243-
}
244-
return undefined;
245-
}
246-
247230
has1to1ConversationWithUser(userId: QualifiedId): boolean {
248231
const foundMLSConversation = this.findMLS1to1Conversation(userId);
249232
if (foundMLSConversation) {

src/script/conversation/EventBuilder.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,12 @@ export const EventBuilder = {
533533
userIds: QualifiedId[],
534534
from: string,
535535
currentTimestamp: number,
536-
reason?: MemberLeaveReason,
537536
): MemberLeaveEvent {
538537
return {
539538
...buildQualifiedId(conversationEntity),
540539
data: {
541540
qualified_user_ids: userIds,
542541
user_ids: userIds.map(({id}) => id),
543-
reason,
544542
},
545543
from: from,
546544
time: conversationEntity.getNextIsoDate(currentTimestamp),

src/script/user/UserRepository.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,7 @@ interface UserAvailabilityEvent {
105105
type: USER.AVAILABILITY;
106106
}
107107

108-
type Events = {
109-
supportedProtocolsUpdated: {user: User; supportedProtocols: ConversationProtocol[]};
110-
userDeleted: QualifiedId;
111-
};
112-
113-
type UserDeleteEventWithQualifiedId = {
114-
id: string;
115-
qualified_id: QualifiedId;
116-
type: USER_EVENT.DELETE;
117-
};
108+
type Events = {supportedProtocolsUpdated: {user: User; supportedProtocols: ConversationProtocol[]}};
118109
export class UserRepository extends TypedEventEmitter<Events> {
119110
private readonly logger: Logger;
120111
public readonly userMapper: UserMapper;
@@ -164,8 +155,7 @@ export class UserRepository extends TypedEventEmitter<Events> {
164155

165156
switch (eventJson.type) {
166157
case USER_EVENT.DELETE:
167-
const userDeleteEvent = eventJson as UserDeleteEventWithQualifiedId;
168-
this.userDelete(userDeleteEvent);
158+
this.userDelete(eventJson);
169159
break;
170160
case USER_EVENT.UPDATE:
171161
await this.onUserUpdate(eventJson, source);
@@ -293,9 +283,9 @@ export class UserRepository extends TypedEventEmitter<Events> {
293283
/**
294284
* Event to delete the matching user.
295285
*/
296-
private userDelete({qualified_id}: {qualified_id: QualifiedId}): void {
286+
private userDelete({id}: {id: string}): void {
297287
// @todo Add user deletion cases for other users
298-
const isSelfUser = matchQualifiedIds(qualified_id, this.userState.self()?.qualifiedId);
288+
const isSelfUser = id === this.userState.self().id;
299289
if (isSelfUser) {
300290
// Info: Deletion of the user causes a database deletion which may interrupt currently running database operations.
301291
// That's why we added a timeout, to leave some time for the database to finish running reads/writes before the
@@ -304,7 +294,6 @@ export class UserRepository extends TypedEventEmitter<Events> {
304294
amplify.publish(WebAppEvents.LIFECYCLE.SIGN_OUT, SIGN_OUT_REASON.ACCOUNT_DELETED, true);
305295
}, 100);
306296
}
307-
this.emit('userDeleted', qualified_id);
308297
}
309298

310299
private async onUserUpdate(eventJson: UserUpdateEvent, source: EventSource): Promise<void> {

src/types/i18n.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ declare module 'I18n/en-US.json' {
555555
'conversationLikesCaptionSingular': `[bold]{userName}[/bold]`;
556556
'conversationLocationLink': `Open Map`;
557557
'conversationMLSMigrationFinalisationOngoingCall': `Due to migration to MLS, you might have issues with your current call. If that\'s the case, hang up and call again.`;
558-
'conversationMemberDeleted': `This user is no longer available`;
559558
'conversationMemberJoined': `[bold]{name}[/bold] added {users} to the conversation`;
560559
'conversationMemberJoinedMore': `[bold]{name}[/bold] added {users}, and [showmore]{count} more[/showmore] to the conversation`;
561560
'conversationMemberJoinedSelf': `[bold]{name}[/bold] joined`;

0 commit comments

Comments
 (0)