Properly yield a 403 error when banned from a supergroup

This commit is contained in:
Bohdan Horbeshko 2025-07-22 14:54:14 -04:00
parent e2c5c78882
commit 74b2dff9f5

View file

@ -601,8 +601,9 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence, mucExt stanza.MucPresen
} }
status := session.GetMyStatusInChat(chatId) status := session.GetMyStatusInChat(chatId)
// TODO: seems to be impossible for basic groups, check back when supergroups are supported log.Debugf("status in group %v: %v", chatId, status)
if status == telegram.ChatMemberStatusBanned { switch status {
case telegram.ChatMemberStatusBanned, telegram.ChatMemberStatusIllegal:
presenceReplySetError(reply, 403) presenceReplySetError(reply, 403)
return return
} }
@ -2093,6 +2094,9 @@ func presenceReplySetError(reply *stanza.Presence, code int) {
case 400: case 400:
reply.Error.Type = stanza.ErrorTypeModify reply.Error.Type = stanza.ErrorTypeModify
reply.Error.Reason = "jid-malformed" reply.Error.Reason = "jid-malformed"
case 403:
reply.Error.Type = stanza.ErrorTypeAuth
reply.Error.Reason = "forbidden"
case 404: case 404:
reply.Error.Type = stanza.ErrorTypeCancel reply.Error.Type = stanza.ErrorTypeCancel
reply.Error.Reason = "item-not-found" reply.Error.Reason = "item-not-found"