Make incoming messages to the transport trigger a subscription

This commit is contained in:
Bohdan Horbeshko 2022-02-13 16:36:18 -05:00
parent 2bf4c6666e
commit 6cbfed8245

View file

@ -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 != "" {