aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmpp/handlers.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index a1f6d74..a7e3c55 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -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
}