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 return
} }
gatewayJid := gateway.Jid.Bare()
session, ok := sessions[bare] session, ok := sessions[bare]
if !ok { if !ok {
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") log.Error("Message from stranger")
return return
} }
}
toID, ok := toToID(msg.To) toID, ok := toToID(msg.To)
if ok { if ok {
session.ProcessOutgoingMessage(toID, msg.Body, msg.From) session.ProcessOutgoingMessage(toID, msg.Body, msg.From)
return return
} else if msg.To == gateway.Jid.Bare() { } else if msg.To == gatewayJid {
if strings.HasPrefix(msg.Body, "/") { if strings.HasPrefix(msg.Body, "/") {
response := session.ProcessTransportCommand(msg.Body, resource) response := session.ProcessTransportCommand(msg.Body, resource)
if response != "" { if response != "" {