Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runfix: Only create a single system message for federation user removal #15967

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/script/conversation/ConversationRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1754,9 +1754,9 @@ export class ConversationRepository {
*/
private async removeMembersLocally(conversation: Conversation, userIds: QualifiedId[]) {
const currentTimestamp = this.serverTimeHandler.toServerTimestamp();
const events = userIds.map(userId => EventBuilder.buildMemberLeave(conversation, userId, true, currentTimestamp));
const event = EventBuilder.buildMemberLeave(conversation, userIds, '', currentTimestamp);
// Injecting the event will trigger all the handlers that will then actually remove the users from the conversation
await this.eventRepository.injectEvents(events, EventRepository.SOURCE.INJECTED);
await this.eventRepository.injectEvent(event);
}

/**
Expand Down Expand Up @@ -1789,7 +1789,7 @@ export class ConversationRepository {
const currentTimestamp = this.serverTimeHandler.toServerTimestamp();
const event = hasResponse
? response.event
: EventBuilder.buildMemberLeave(conversationEntity, user, true, currentTimestamp);
: EventBuilder.buildMemberLeave(conversationEntity, [user], this.userState.self().id, currentTimestamp);

this.eventRepository.injectEvent(event, EventRepository.SOURCE.BACKEND_RESPONSE);
return event;
Expand Down
10 changes: 5 additions & 5 deletions src/script/conversation/EventBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -476,17 +476,17 @@ export const EventBuilder = {

buildMemberLeave(
conversationEntity: Conversation,
userId: QualifiedId,
removedBySelfUser: boolean,
userIds: QualifiedId[],
from: string,
currentTimestamp: number,
): MemberLeaveEvent {
return {
...buildQualifiedId(conversationEntity),
data: {
qualified_user_ids: [userId],
user_ids: [userId.id],
qualified_user_ids: userIds,
user_ids: userIds.map(({id}) => id),
},
from: removedBySelfUser ? conversationEntity.selfUser().id : userId.id,
from: from,
time: conversationEntity.getNextIsoDate(currentTimestamp),
type: CONVERSATION_EVENT.MEMBER_LEAVE,
};
Expand Down
2 changes: 1 addition & 1 deletion src/script/entity/message/MemberMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export class MemberMessage extends SystemMessage {
}

const allUsers = this.generateNameString();
if (!this.user().isMe && !name) {
if (!this.user().id) {
return t('conversationMemberWereRemoved', allUsers);
}
return this.user().isMe
Expand Down