diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index c668ec71a..5749da7b8 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -518,6 +518,11 @@ type CommunityShard struct { Shard *common.Shard `json:"shard"` } +type CommunityShard struct { + CommunityID string `json:"communityID"` + Shard *common.Shard `json:"shard"` +} + type KnownCommunitiesResponse struct { ContractCommunities []string `json:"contractCommunities"` // TODO: use CommunityShard ContractFeaturedCommunities []string `json:"contractFeaturedCommunities"` // TODO: use CommunityShard diff --git a/protocol/messenger_share_urls.go b/protocol/messenger_share_urls.go index 94f37ab48..5a501c58c 100644 --- a/protocol/messenger_share_urls.go +++ b/protocol/messenger_share_urls.go @@ -138,6 +138,13 @@ func (m *Messenger) prepareEncodedCommunityData(community *communities.Community return "", "", err } + shardCluster := int32(common.UndefinedShardValue) + shardIndex := int32(common.UndefinedShardValue) + if community.Shard() != nil { + shardCluster = int32(community.Shard().Cluster) + shardIndex = int32(community.Shard().Index) + } + urlDataProto := &protobuf.URLData{ Content: communityData, Shard: community.Shard().Protobuffer(), @@ -202,6 +209,14 @@ func (m *Messenger) parseCommunityURLWithData(data string, chatKey string) (*URL return nil, err } + var shard *common.Shard + if urlDataProto.ShardCluster != common.UndefinedShardValue && urlDataProto.ShardIndex != common.UndefinedShardValue { + shard = &common.Shard{ + Cluster: uint16(urlDataProto.ShardCluster), + Index: uint16(urlDataProto.ShardIndex), + } + } + return &URLDataResponse{ Community: CommunityURLData{ DisplayName: communityProto.DisplayName, @@ -305,6 +320,14 @@ func (m *Messenger) prepareEncodedCommunityChannelData(community *communities.Co return "", "", err } + shardCluster := int32(common.UndefinedShardValue) + shardIndex := int32(common.UndefinedShardValue) + if community.Shard() != nil { + shardCluster = int32(community.Shard().Cluster) + shardIndex = int32(community.Shard().Index) + + } + urlDataProto := &protobuf.URLData{ Content: channelData, Shard: community.Shard().Protobuffer(), @@ -382,6 +405,14 @@ func (m *Messenger) parseCommunityChannelURLWithData(data string, chatKey string return nil, err } + var shard *common.Shard + if urlDataProto.ShardCluster != common.UndefinedShardValue && urlDataProto.ShardIndex != common.UndefinedShardValue { + shard = &common.Shard{ + Cluster: uint16(urlDataProto.ShardCluster), + Index: uint16(urlDataProto.ShardIndex), + } + } + return &URLDataResponse{ Community: CommunityURLData{ DisplayName: channelProto.Community.DisplayName,