Skip to content

Commit

Permalink
fix(chat/api): make community chat creation more forgiving and accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
jrainville committed Oct 19, 2023
1 parent c423801 commit 071fbc5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions services/chat/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,19 @@ func (api *API) getChannelGroups(ctx context.Context, channelGroupID string) (ma
}
}

for _, chat := range channels {
if chat.CommunityID == community.IDString() && chat.Active {
// Looping The community's chats first makes sure we only get the chats that are reallay part of the community
for communityChatID, _ := range community.Chats() {
for _, chat := range channels {
if communityChatID != chat.CommunityChatID() || !chat.Active {
continue
}
c, err := api.toAPIChat(chat, community, pubKey, true)
if err != nil {
return nil, err
}

chGrp.Chats[c.ID] = c
break
}
}

Expand Down Expand Up @@ -421,7 +426,8 @@ func getChatMembers(sourceChat *protocol.Chat, community *communities.Community,
if community != nil {
channel, exists := community.Chats()[sourceChat.CommunityChatID()]
if !exists {
return result, communities.ErrChatNotFound
// Skip unknown community chats. They might be channels that were deleted
return result, nil
}
for member := range channel.Members {
pubKey, err := common.HexToPubkey(member)
Expand Down

0 comments on commit 071fbc5

Please sign in to comment.