aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmpp/handlers.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index 6f8c877..eeb9628 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -71,17 +71,24 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) {
return
}
+ gatewayJid := gateway.Jid.Bare()
+
session, ok := sessions[bare]
if !ok {
- log.Error("Message from stranger")
- return
+ if msg.To == gatewayJid {
+ gateway.SendPresence(component, msg.From, gateway.SPType("subscribe"))
+ gateway.SendPresence(component, msg.From, gateway.SPType("subscribed"))
+ } else {
+ log.Error("Message from stranger")
+ return
+ }
}
toID, ok := toToID(msg.To)
if ok {
session.ProcessOutgoingMessage(toID, msg.Body, msg.From)
return
- } else if msg.To == gateway.Jid.Bare() {
+ } else if msg.To == gatewayJid {
if strings.HasPrefix(msg.Body, "/") {
response := session.ProcessTransportCommand(msg.Body, resource)
if response != "" {