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.
This commit is contained in:
parent
fde4db01fa
commit
2b3f417b24
2 changed files with 12 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue