Compare commits

..

2 commits

Author SHA1 Message Date
97711c9d2e Merge branch 'fix/channel-admin-clear-banned-rights'
Some checks are pending
CI / Go tests (push) Waiting to run
CI / Admin web build (push) Waiting to run
CI / Grammy store bot (push) Waiting to run
CI / Docker main topology smoke (push) Waiting to run
2026-09-15 12:11:09 +01:00
2b3f417b24 channels: clear stale banned rights when promoting a member to admin
EditChannelAdmin reactivates a previously kicked/banned member to Active
status but left BannedRights.ViewMessages set from the old ban, an
Active+banned-from-viewing state nothing else in the codebase expects.
TransferChannelOwnership's participant check trips on it and rejects the
transfer with PARTICIPANT_MISSING, even though the target is now a
visibly active admin.
2026-09-15 12:11:04 +01:00
2 changed files with 12 additions and 0 deletions

View file

@ -347,6 +347,11 @@ func (s *ChannelStore) EditChannelAdmin(_ context.Context, req domain.EditChanne
member.InviterUserID = req.UserID member.InviterUserID = req.UserID
member.Status = domain.ChannelMemberActive member.Status = domain.ChannelMemberActive
member.LeftAt = 0 member.LeftAt = 0
// See the postgres EditChannelAdmin implementation for why this is
// needed: a kicked/banned member carries BannedRights.ViewMessages=true,
// and editAdmin unconditionally reactivates them to Active, so any
// lingering ban must be lifted too.
member.BannedRights = domain.ChannelBannedRights{}
if previous.Status != domain.ChannelMemberActive { if previous.Status != domain.ChannelMemberActive {
if minPts := channelInitialAvailableMinPts(channel); minPts > member.AvailableMinPts { if minPts := channelInitialAvailableMinPts(channel); minPts > member.AvailableMinPts {
member.AvailableMinPts = minPts member.AvailableMinPts = minPts

View file

@ -100,6 +100,13 @@ func (s *ChannelStore) EditChannelAdmin(ctx context.Context, req domain.EditChan
member.InviterUserID = req.UserID member.InviterUserID = req.UserID
member.Status = domain.ChannelMemberActive member.Status = domain.ChannelMemberActive
member.LeftAt = 0 member.LeftAt = 0
// A kicked/banned member carries BannedRights.ViewMessages=true (see
// EditChannelBanned above); editAdmin unconditionally reactivates them
// to Active, so any lingering ban must be lifted too -- otherwise the
// contradictory Active+ViewMessages-banned state trips later checks
// (e.g. TransferChannelOwnership's participant check) that never
// expect an active member to be ban-restricted from viewing messages.
member.BannedRights = domain.ChannelBannedRights{}
if req.HasRank() { if req.HasRank() {
member.Rank = req.Rank member.Rank = req.Rank
} }