Clean up protocol package (#1890)

This commit is contained in:
Adam Babik 2020-03-09 07:19:23 +01:00 committed by GitHub
parent 2d1e06f25f
commit 17f91b3141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 12 deletions

View File

@ -5,5 +5,5 @@ import (
)
func newProtocolGroupFromChat(chat *Chat) (*v1protocol.Group, error) {
return v1protocol.NewGroup(chat.ID, chat.MembershipUpdates)
return v1protocol.NewGroupWithEvents(chat.ID, chat.MembershipUpdates)
}

View File

@ -79,7 +79,7 @@ func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageSta
return errors.Wrap(err, "invalid membership update")
}
merged := v1protocol.MergeMembershipUpdateEvents(existingGroup.Events(), updateGroup.Events())
group, err = v1protocol.NewGroup(chat.ID, merged)
group, err = v1protocol.NewGroupWithEvents(chat.ID, merged)
if err != nil {
return errors.Wrap(err, "failed to create a group with new membership updates")
}

View File

@ -1736,6 +1736,8 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
continue
}
logger.Debug("processing messages further", zap.Int("count", len(statusMessages)))
for _, msg := range statusMessages {
publicKey := msg.SigPubKey()
@ -1896,11 +1898,9 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
logger.Warn("failed to handle ContactUpdate", zap.Error(err))
continue
}
default:
// RawMessage, not processed here, pass straight to the client
rawMessages[chat] = append(rawMessages[chat], msg)
}
} else {
logger.Debug("Adding raw message", zap.Any("msg", msg))

View File

@ -242,10 +242,6 @@ func NewGroupWithCreator(name string, clock uint64, creator *ecdsa.PrivateKey) (
return newGroup(chatID, []MembershipUpdateEvent{chatCreated})
}
func NewGroup(chatID string, events []MembershipUpdateEvent) (*Group, error) {
return newGroup(chatID, events)
}
func newGroup(chatID string, events []MembershipUpdateEvent) (*Group, error) {
g := Group{
chatID: chatID,
@ -293,14 +289,14 @@ func (g Group) ChatID() string {
return g.chatID
}
func (g Group) Events() []MembershipUpdateEvent {
return g.events
}
func (g Group) Name() string {
return g.name
}
func (g Group) Events() []MembershipUpdateEvent {
return g.events
}
func (g Group) Members() []string {
return g.members.List()
}