Skip to content

Commit

Permalink
fix: ensure community channels are dehydrated on publish
Browse files Browse the repository at this point in the history
  • Loading branch information
osmaczko committed Sep 26, 2023
1 parent 3bda9ca commit 5a4cc50
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions protocol/communities/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,11 @@ func (o *Community) Description() *protobuf.CommunityDescription {
}

func (o *Community) marshaledDescription() ([]byte, error) {
return proto.Marshal(o.config.CommunityDescription)
// This is only workaround to lower the size of the message that goes over the wire,
// see https://github.com/status-im/status-desktop/issues/12188
clone := o.CreateDeepCopy()
clone.DehydrateChannelsMembers()
return proto.Marshal(clone.config.CommunityDescription)
}

func (o *Community) MarshaledDescription() ([]byte, error) {
Expand All @@ -1241,14 +1245,14 @@ func (o *Community) MarshaledDescription() ([]byte, error) {
}

func (o *Community) toProtocolMessageBytes() ([]byte, error) {
// This should not happen, as we can only serialize on our side if we
// created the community
if !o.IsControlNode() && len(o.config.CommunityDescriptionProtocolMessage) == 0 {
return nil, ErrNotControlNode
}

// If we are not a control node, use the received serialized version
if !o.IsControlNode() {
// This should not happen, as we can only serialize on our side if we
// created the community
if len(o.config.CommunityDescriptionProtocolMessage) == 0 {
return nil, ErrNotControlNode
}

return o.config.CommunityDescriptionProtocolMessage, nil
}

Expand All @@ -1265,15 +1269,6 @@ func (o *Community) toProtocolMessageBytes() ([]byte, error) {
func (o *Community) ToProtocolMessageBytes() ([]byte, error) {
o.mutex.Lock()
defer o.mutex.Unlock()

// This is only workaround to lower the size of the message that goes over the wire,
// see https://github.com/status-im/status-desktop/issues/12188
if o.IsControlNode() {
clone := o.CreateDeepCopy()
clone.DehydrateChannelsMembers()
return clone.toProtocolMessageBytes()
}

return o.toProtocolMessageBytes()
}

Expand Down

0 comments on commit 5a4cc50

Please sign in to comment.