Don't send new members event when there are no new members

This commit is contained in:
Volodymyr Kozieiev 2020-10-30 13:26:08 +02:00 committed by Andrea Maria Piana
parent d04e54e54e
commit 9dffff042e
2 changed files with 14 additions and 10 deletions

View File

@ -1 +1 @@
0.62.16
0.62.17

View File

@ -723,18 +723,22 @@ func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string,
chat.updateChatFromGroupMembershipChanges(contactIDFromPublicKey(&m.identity.PublicKey), group)
clock, _ = chat.NextClockAndTimestamp(m.getTimesource())
// Add members
event := v1protocol.NewMembersAddedEvent(members, clock)
event.ChatID = chat.ID
err = event.Sign(m.identity)
if err != nil {
return nil, err
if len(members) > 0 {
event := v1protocol.NewMembersAddedEvent(members, clock)
event.ChatID = chat.ID
err = event.Sign(m.identity)
if err != nil {
return nil, err
}
err = group.ProcessEvent(event)
if err != nil {
return nil, err
}
}
err = group.ProcessEvent(event)
if err != nil {
return nil, err
}
recipients, err := stringSliceToPublicKeys(group.Members(), true)
if err != nil {
return nil, err