aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--go.mod2
-rw-r--r--go.sum2
-rw-r--r--telegram/client.go7
-rw-r--r--telegram/utils.go2
-rw-r--r--xmpp/component.go7
-rw-r--r--xmpp/handlers.go5
6 files changed, 14 insertions, 11 deletions
diff --git a/go.mod b/go.mod
index 6c55590..41f4e67 100644
--- a/go.mod
+++ b/go.mod
@@ -13,4 +13,4 @@ require (
gosrc.io/xmpp v0.5.2-0.20211214110136-5f99e1cd06e1
)
-replace gosrc.io/xmpp => dev.narayana.im/narayana/go-xmpp v0.0.0-20211218155535-e55463fc9829
+replace gosrc.io/xmpp => dev.narayana.im/narayana/go-xmpp v0.0.0-20220524203317-306b4ff58e8f
diff --git a/go.sum b/go.sum
index 2ca2008..5fa5f81 100644
--- a/go.sum
+++ b/go.sum
@@ -1,5 +1,7 @@
dev.narayana.im/narayana/go-xmpp v0.0.0-20211218155535-e55463fc9829 h1:qe81G6+t1V1ySRMa7lSu5CayN5aP5GEiHXL2DYwHzuA=
dev.narayana.im/narayana/go-xmpp v0.0.0-20211218155535-e55463fc9829/go.mod h1:L3NFMqYOxyLz3JGmgFyWf7r9htE91zVGiK40oW4RwdY=
+dev.narayana.im/narayana/go-xmpp v0.0.0-20220524203317-306b4ff58e8f h1:6249ajbMjgYz53Oq0IjTvjHXbxTfu29Mj1J/6swRHs4=
+dev.narayana.im/narayana/go-xmpp v0.0.0-20220524203317-306b4ff58e8f/go.mod h1:L3NFMqYOxyLz3JGmgFyWf7r9htE91zVGiK40oW4RwdY=
github.com/Arman92/go-tdlib v0.0.0-20191002071913-526f4e1d15f7 h1:GbV1Lv3lVHsSeKAqPTBem72OCsGjXntW4jfJdXciE+w=
github.com/Arman92/go-tdlib v0.0.0-20191002071913-526f4e1d15f7/go.mod h1:ZzkRfuaFj8etIYMj/ECtXtgfz72RE6U+dos27b3XIwk=
github.com/agnivade/wasmbrowsertest v0.3.1/go.mod h1:zQt6ZTdl338xxRaMW395qccVE2eQm0SjC/SDz0mPWQI=
diff --git a/telegram/client.go b/telegram/client.go
index 7c3d904..49816db 100644
--- a/telegram/client.go
+++ b/telegram/client.go
@@ -48,7 +48,6 @@ type Client struct {
options []client.Option
me *client.User
- resource string
xmpp *xmpp.Component
jid string
Session *persistence.Session
@@ -116,14 +115,8 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
IgnoreFileNames: false,
}
- resource := conf.Tdlib.Client.DeviceModel
- if resource == "" {
- resource = "telegabber"
- }
-
return &Client{
parameters: &parameters,
- resource: resource,
xmpp: component,
jid: jid,
Session: session,
diff --git a/telegram/utils.go b/telegram/utils.go
index 1248a54..61fefa7 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -225,7 +225,7 @@ func (c *Client) ProcessStatusUpdate(chatID int64, status string, show string, o
gateway.SPShow(show),
gateway.SPStatus(status),
gateway.SPPhoto(photo),
- gateway.SPResource(c.resource),
+ gateway.SPResource(gateway.Jid.Resource),
gateway.SPImmed(gateway.SPImmed.Get(oldArgs)),
}
if presenceType != "" {
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)