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
|
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,
|
From: toBare,
|
||||||
To: p.From,
|
To: p.From,
|
||||||
Id: p.Id,
|
Id: p.Id,
|
||||||
|
@ -428,31 +430,31 @@ func handleMUCPresence(s xmpp.Sender, p stanza.Presence) {
|
||||||
defer gateway.ResumableSend(component, reply)
|
defer gateway.ResumableSend(component, reply)
|
||||||
|
|
||||||
if nickname == "" {
|
if nickname == "" {
|
||||||
presenceReplySetError(&reply, 400)
|
presenceReplySetError(reply, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
chatId, ok := toToID(toBare)
|
chatId, ok := toToID(toBare)
|
||||||
if !ok {
|
if !ok {
|
||||||
presenceReplySetError(&reply, 404)
|
presenceReplySetError(reply, 404)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fromBare, _, ok := gateway.SplitJID(p.From)
|
fromBare, _, ok := gateway.SplitJID(p.From)
|
||||||
if !ok {
|
if !ok {
|
||||||
presenceReplySetError(&reply, 400)
|
presenceReplySetError(reply, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
session, ok := sessions[fromBare]
|
session, ok := sessions[fromBare]
|
||||||
if !ok || !session.Session.MUC {
|
if !ok || !session.Session.MUC {
|
||||||
presenceReplySetError(&reply, 401)
|
presenceReplySetError(reply, 401)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
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, 404)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue