Fix returning MUC join errors
This commit is contained in:
parent
93abbe834e
commit
c1887e5a1e
|
@ -420,7 +420,9 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence) {
|
|||
return
|
||||
}
|
||||
|
||||
reply := stanza.Presence{Attrs: stanza.Attrs{
|
||||
// separate declaration is crucial for passing as pointer to defer
|
||||
var reply *stanza.Presence
|
||||
reply = &stanza.Presence{Attrs: stanza.Attrs{
|
||||
From: toBare,
|
||||
To: p.From,
|
||||
Id: p.Id,
|
||||
|
@ -428,31 +430,31 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence) {
|
|||
defer gateway.ResumableSend(component, reply)
|
||||
|
||||
if nickname == "" {
|
||||
presenceReplySetError(&reply, 400)
|
||||
presenceReplySetError(reply, 400)
|
||||
return
|
||||
}
|
||||
|
||||
chatId, ok := toToID(toBare)
|
||||
if !ok {
|
||||
presenceReplySetError(&reply, 404)
|
||||
presenceReplySetError(reply, 404)
|
||||
return
|
||||
}
|
||||
|
||||
fromBare, _, ok := gateway.SplitJID(p.From)
|
||||
if !ok {
|
||||
presenceReplySetError(&reply, 400)
|
||||
presenceReplySetError(reply, 400)
|
||||
return
|
||||
}
|
||||
|
||||
session, ok := sessions[fromBare]
|
||||
if !ok || !session.Session.MUC {
|
||||
presenceReplySetError(&reply, 401)
|
||||
presenceReplySetError(reply, 401)
|
||||
return
|
||||
}
|
||||
|
||||
chat, _, err := session.GetContactByID(chatId, nil)
|
||||
if err != nil || !session.IsGroup(chat) {
|
||||
presenceReplySetError(&reply, 404)
|
||||
presenceReplySetError(reply, 404)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue