Clean up protocol package (#1890)
This commit is contained in:
parent
2d1e06f25f
commit
17f91b3141
|
@ -5,5 +5,5 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func newProtocolGroupFromChat(chat *Chat) (*v1protocol.Group, error) {
|
func newProtocolGroupFromChat(chat *Chat) (*v1protocol.Group, error) {
|
||||||
return v1protocol.NewGroup(chat.ID, chat.MembershipUpdates)
|
return v1protocol.NewGroupWithEvents(chat.ID, chat.MembershipUpdates)
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageSta
|
||||||
return errors.Wrap(err, "invalid membership update")
|
return errors.Wrap(err, "invalid membership update")
|
||||||
}
|
}
|
||||||
merged := v1protocol.MergeMembershipUpdateEvents(existingGroup.Events(), updateGroup.Events())
|
merged := v1protocol.MergeMembershipUpdateEvents(existingGroup.Events(), updateGroup.Events())
|
||||||
group, err = v1protocol.NewGroup(chat.ID, merged)
|
group, err = v1protocol.NewGroupWithEvents(chat.ID, merged)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "failed to create a group with new membership updates")
|
return errors.Wrap(err, "failed to create a group with new membership updates")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1736,6 +1736,8 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Debug("processing messages further", zap.Int("count", len(statusMessages)))
|
||||||
|
|
||||||
for _, msg := range statusMessages {
|
for _, msg := range statusMessages {
|
||||||
publicKey := msg.SigPubKey()
|
publicKey := msg.SigPubKey()
|
||||||
|
|
||||||
|
@ -1896,11 +1898,9 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
|
||||||
logger.Warn("failed to handle ContactUpdate", zap.Error(err))
|
logger.Warn("failed to handle ContactUpdate", zap.Error(err))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// RawMessage, not processed here, pass straight to the client
|
// RawMessage, not processed here, pass straight to the client
|
||||||
rawMessages[chat] = append(rawMessages[chat], msg)
|
rawMessages[chat] = append(rawMessages[chat], msg)
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Debug("Adding raw message", zap.Any("msg", msg))
|
logger.Debug("Adding raw message", zap.Any("msg", msg))
|
||||||
|
|
|
@ -242,10 +242,6 @@ func NewGroupWithCreator(name string, clock uint64, creator *ecdsa.PrivateKey) (
|
||||||
return newGroup(chatID, []MembershipUpdateEvent{chatCreated})
|
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) {
|
func newGroup(chatID string, events []MembershipUpdateEvent) (*Group, error) {
|
||||||
g := Group{
|
g := Group{
|
||||||
chatID: chatID,
|
chatID: chatID,
|
||||||
|
@ -293,14 +289,14 @@ func (g Group) ChatID() string {
|
||||||
return g.chatID
|
return g.chatID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g Group) Events() []MembershipUpdateEvent {
|
|
||||||
return g.events
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g Group) Name() string {
|
func (g Group) Name() string {
|
||||||
return g.name
|
return g.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g Group) Events() []MembershipUpdateEvent {
|
||||||
|
return g.events
|
||||||
|
}
|
||||||
|
|
||||||
func (g Group) Members() []string {
|
func (g Group) Members() []string {
|
||||||
return g.members.List()
|
return g.members.List()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue