Skip to content

Commit

Permalink
fix: add all members to channel when it is no longer token-gated
Browse files Browse the repository at this point in the history
  • Loading branch information
osmaczko committed Jul 26, 2023
1 parent 439be82 commit 83332ab
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions protocol/communities/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -2213,6 +2213,8 @@ func (o *Community) updateTokenPermission(permission *protobuf.CommunityTokenPer
return changes, nil
}

const pkStringLength = 68

func (o *Community) deleteTokenPermission(permissionID string) (*CommunityChanges, error) {
permission, exists := o.config.CommunityDescription.TokenPermissions[permissionID]
if !exists {
Expand All @@ -2222,6 +2224,19 @@ func (o *Community) deleteTokenPermission(permissionID string) (*CommunityChange
delete(o.config.CommunityDescription.TokenPermissions, permissionID)

changes := o.emptyCommunityChanges()

for _, chatID := range permission.ChatIds {
// if channel token permissions have been removed, add back all members to the channel
if !o.ChannelHasTokenPermissions(chatID) {
channelID := chatID[pkStringLength:] // FIXME: permission.ChatIds should be already stripped
var err error
changes, err = o.populateChatWithAllMembers(channelID)
if err != nil {
return changes, err
}
}
}

changes.TokenPermissionsRemoved[permissionID] = permission
return changes, nil
}
Expand Down

0 comments on commit 83332ab

Please sign in to comment.