diff options
author | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-05-26 14:14:38 +0300 |
---|---|---|
committer | Bohdan Horbeshko <bodqhrohro@gmail.com> | 2022-05-26 14:14:38 +0300 |
commit | 70841a2bea61728c75f6675bcd3355e8dfdcd087 (patch) | |
tree | 2405e12fb7f306a0f64725a5631bfb5d7f509e43 /xmpp | |
parent | ae16fd2a0b48c3659a012accd0269323935dfd14 (diff) |
Always send XMPP messages with a resource
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/component.go | 7 | ||||
-rw-r--r-- | xmpp/handlers.go | 5 |
2 files changed, 10 insertions, 2 deletions
diff --git a/xmpp/component.go b/xmpp/component.go index f5143ea..0f23d50 100644 --- a/xmpp/component.go +++ b/xmpp/component.go @@ -45,6 +45,13 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea if err != nil { return nil, nil, err } + if gateway.Jid.Resource == "" { + if tc.Tdlib.Client.DeviceModel != "" { + gateway.Jid.Resource = tc.Tdlib.Client.DeviceModel + } else { + gateway.Jid.Resource = "telegabber" + } + } tgConf = tc diff --git a/xmpp/handlers.go b/xmpp/handlers.go index b4440a0..d68838b 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -88,8 +88,9 @@ func HandleMessage(s xmpp.Sender, p stanza.Packet) { if ok { session.ProcessOutgoingMessage(toID, msg.Body, msg.From) return - } else if msg.To == gatewayJid { - if strings.HasPrefix(msg.Body, "/") || strings.HasPrefix(msg.Body, "!") { + } else { + toJid, err := stanza.NewJid(msg.To) + if err == nil && toJid.Bare() == gatewayJid && (strings.HasPrefix(msg.Body, "/") || strings.HasPrefix(msg.Body, "!")) { response := session.ProcessTransportCommand(msg.Body, resource) if response != "" { gateway.SendMessage(msg.From, "", response, component) |