Return 405 for non-existent room JIDs as this should be considered a room creation attempt

This commit is contained in:
Bohdan Horbeshko 2025-06-17 03:04:43 -04:00
parent 746a537cb9
commit 174037e63f

View file

@ -561,7 +561,7 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence, mucExt stanza.MucPresen
chatId, ok, toIsGroup := toToID(toBare) chatId, ok, toIsGroup := toToID(toBare)
if !ok || !toIsGroup { if !ok || !toIsGroup {
presenceReplySetError(reply, 404) presenceReplySetError(reply, 405)
return return
} }
@ -579,7 +579,7 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence, mucExt stanza.MucPresen
chat, _, err := session.GetContactByID(chatId, nil) chat, _, err := session.GetContactByID(chatId, nil)
if err != nil || !session.IsGroup(chat) { if err != nil || !session.IsGroup(chat) {
presenceReplySetError(reply, 404) presenceReplySetError(reply, 405)
return return
} }
@ -1862,9 +1862,9 @@ func presenceReplySetError(reply *stanza.Presence, code int) {
case 407: case 407:
reply.Error.Type = stanza.ErrorTypeAuth reply.Error.Type = stanza.ErrorTypeAuth
reply.Error.Reason = "registration-required" reply.Error.Reason = "registration-required"
case 404: case 405:
reply.Error.Type = stanza.ErrorTypeCancel reply.Error.Type = stanza.ErrorTypeCancel
reply.Error.Reason = "item-not-found" reply.Error.Reason = "not-allowed"
default: default:
log.Error("Unknown error code, falling back with empty reason") log.Error("Unknown error code, falling back with empty reason")
reply.Error.Type = stanza.ErrorTypeCancel reply.Error.Type = stanza.ErrorTypeCancel