refactor: extract Community.ChatID
This commit is contained in:
parent
667e427b63
commit
4fddcb54ff
|
@ -1427,7 +1427,7 @@ func (o *Community) DehydrateChannelsMembers() {
|
|||
// To save space, we don't attach members for channels without permissions,
|
||||
// otherwise the message will hit waku msg size limit.
|
||||
for channelID, channel := range o.chats() {
|
||||
if !o.ChannelHasTokenPermissions(o.IDString() + channelID) {
|
||||
if !o.ChannelHasTokenPermissions(o.ChatID(channelID)) {
|
||||
channel.Members = map[string]*protobuf.CommunityMember{} // clean members
|
||||
}
|
||||
}
|
||||
|
@ -1603,7 +1603,7 @@ func (o *Community) HasTokenPermissions() bool {
|
|||
}
|
||||
|
||||
func (o *Community) ChannelEncrypted(channelID string) bool {
|
||||
return o.ChannelHasTokenPermissions(o.IDString() + channelID)
|
||||
return o.ChannelHasTokenPermissions(o.ChatID(channelID))
|
||||
}
|
||||
|
||||
func (o *Community) ChannelHasTokenPermissions(chatID string) bool {
|
||||
|
@ -2084,9 +2084,13 @@ func (o *Community) populateChatWithAllMembers(chatID string) (*CommunityChanges
|
|||
return result, nil
|
||||
}
|
||||
|
||||
func (o *Community) ChatID(channelID string) string {
|
||||
return o.IDString() + channelID
|
||||
}
|
||||
|
||||
func (o *Community) ChatIDs() (chatIDs []string) {
|
||||
for id := range o.config.CommunityDescription.Chats {
|
||||
chatIDs = append(chatIDs, o.IDString()+id)
|
||||
for channelID := range o.config.CommunityDescription.Chats {
|
||||
chatIDs = append(chatIDs, o.ChatID(channelID))
|
||||
}
|
||||
return chatIDs
|
||||
}
|
||||
|
|
|
@ -959,7 +959,7 @@ func (m *Manager) ReevaluateMembers(community *Community) (map[protobuf.Communit
|
|||
|
||||
// Validate channel permissions
|
||||
for channelID := range community.Chats() {
|
||||
chatID := community.IDString() + channelID
|
||||
chatID := community.ChatID(channelID)
|
||||
|
||||
viewOnlyPermissions := community.ChannelTokenPermissionsByType(chatID, protobuf.CommunityTokenPermission_CAN_VIEW_CHANNEL)
|
||||
viewAndPostPermissions := community.ChannelTokenPermissionsByType(chatID, protobuf.CommunityTokenPermission_CAN_VIEW_AND_POST_CHANNEL)
|
||||
|
|
Loading…
Reference in New Issue