From 4084c9d82c3fd421b5b9b3d398f3a57e86bc1db8 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 8 Jan 2021 20:33:19 +0100 Subject: [PATCH] Don't resend automatically group chat messages Since we fixed re-sending of messages, it has been noticed a performance degradation in private group chats. This is due to too aggressive re-sending of messages. This commit disables resending of private group chat messages for now (same as 1.9, so no changes), but keeps it enabled for 1-to-1s. --- protocol/messenger.go | 63 +++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 35 deletions(-) diff --git a/protocol/messenger.go b/protocol/messenger.go index aefb145a5..305bff06c 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -1216,11 +1216,10 @@ func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string, m.allChats[chat.ID] = &chat _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: recipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: recipients, }) if err != nil { @@ -1299,11 +1298,10 @@ func (m *Messenger) RemoveMemberFromGroupChat(ctx context.Context, chatID string return nil, err } _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: oldRecipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: oldRecipients, }) if err != nil { return nil, err @@ -1388,11 +1386,10 @@ func (m *Messenger) AddMembersToGroupChat(ctx context.Context, chatID string, me return nil, err } _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: recipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: recipients, }) if err != nil { @@ -1453,11 +1450,10 @@ func (m *Messenger) ChangeGroupChatName(ctx context.Context, chatID string, name return nil, err } _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: recipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: recipients, }) if err != nil { @@ -1664,11 +1660,10 @@ func (m *Messenger) AddAdminsToGroupChat(ctx context.Context, chatID string, mem return nil, err } _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: recipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: recipients, }) if err != nil { @@ -1732,11 +1727,10 @@ func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chatID string) (*Me return nil, err } _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: recipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: recipients, }) if err != nil { return nil, err @@ -1800,11 +1794,10 @@ func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string, remove bo return nil, err } _, err = m.dispatchMessage(ctx, common.RawMessage{ - LocalChatID: chat.ID, - Payload: encodedMessage, - MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, - Recipients: recipients, - ResendAutomatically: true, + LocalChatID: chat.ID, + Payload: encodedMessage, + MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, + Recipients: recipients, }) if err != nil { return nil, err