aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-14 00:36:18 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-14 00:36:18 +0300
commit6cbfed824520e742532db502147d9c6bc524cc84 (patch)
treebbf9b196c906bb5ae3fc555034b1afd0006e2483
parent2bf4c6666ea7a9703ca1c70ca555bc4b13dfbf21 (diff)
Make incoming messages to the transport trigger a subscription
-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 != "" {