From 61908d1ac27ab3504345b141852501784cbae7d4 Mon Sep 17 00:00:00 2001 From: Astra Date: Wed, 16 Sep 2026 14:35:15 +0100 Subject: [PATCH] channels: fix getParticipant returning success for a left/kicked member GetParticipant only converted a stale "left" row into USER_NOT_PARTICIPANT when the participant being queried was the viewer themselves. Querying about a different user who previously left/was kicked returned their stale row as a successful result instead, which a client can't classify as a proper participant type. Check the status regardless of who's asking. --- internal/store/postgres/channel_member_list.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/store/postgres/channel_member_list.go b/internal/store/postgres/channel_member_list.go index ced215d5..985b0fce 100644 --- a/internal/store/postgres/channel_member_list.go +++ b/internal/store/postgres/channel_member_list.go @@ -184,7 +184,12 @@ func (s *ChannelStore) GetParticipant(ctx context.Context, viewerUserID, channel if errors.Is(err, domain.ErrChannelPrivate) { return domain.ChannelMember{}, domain.ErrUserNotParticipant } - if err == nil && participantUserID == viewerUserID && member.Status == domain.ChannelMemberLeft { + // A stale row for a former member (left/kicked) is not a current + // participant for any caller, not just a self-check: channels.getParticipant + // on someone who has left must surface USER_NOT_PARTICIPANT like a missing + // row does, or callers get a "successful" ChannelParticipantLeft result for + // what protocol-wise is an absent participant. + if err == nil && member.Status != domain.ChannelMemberActive { return domain.ChannelMember{}, domain.ErrUserNotParticipant } return member, err