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.
This commit is contained in:
Andrea Maria Piana 2021-01-08 20:33:19 +01:00
parent cd21f9b0e2
commit 4084c9d82c
1 changed files with 28 additions and 35 deletions

View File

@ -1216,11 +1216,10 @@ func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string,
m.allChats[chat.ID] = &chat m.allChats[chat.ID] = &chat
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: recipients, Recipients: recipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
@ -1299,11 +1298,10 @@ func (m *Messenger) RemoveMemberFromGroupChat(ctx context.Context, chatID string
return nil, err return nil, err
} }
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: oldRecipients, Recipients: oldRecipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
@ -1388,11 +1386,10 @@ func (m *Messenger) AddMembersToGroupChat(ctx context.Context, chatID string, me
return nil, err return nil, err
} }
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: recipients, Recipients: recipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
@ -1453,11 +1450,10 @@ func (m *Messenger) ChangeGroupChatName(ctx context.Context, chatID string, name
return nil, err return nil, err
} }
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: recipients, Recipients: recipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
@ -1664,11 +1660,10 @@ func (m *Messenger) AddAdminsToGroupChat(ctx context.Context, chatID string, mem
return nil, err return nil, err
} }
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: recipients, Recipients: recipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
@ -1732,11 +1727,10 @@ func (m *Messenger) ConfirmJoiningGroup(ctx context.Context, chatID string) (*Me
return nil, err return nil, err
} }
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: recipients, Recipients: recipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
@ -1800,11 +1794,10 @@ func (m *Messenger) LeaveGroupChat(ctx context.Context, chatID string, remove bo
return nil, err return nil, err
} }
_, err = m.dispatchMessage(ctx, common.RawMessage{ _, err = m.dispatchMessage(ctx, common.RawMessage{
LocalChatID: chat.ID, LocalChatID: chat.ID,
Payload: encodedMessage, Payload: encodedMessage,
MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE, MessageType: protobuf.ApplicationMetadataMessage_MEMBERSHIP_UPDATE_MESSAGE,
Recipients: recipients, Recipients: recipients,
ResendAutomatically: true,
}) })
if err != nil { if err != nil {
return nil, err return nil, err