Always send XMPP messages with a resource
This commit is contained in:
parent
ae16fd2a0b
commit
70841a2bea
2
go.mod
2
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
|
||||
|
|
2
go.sum
2
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=
|
||||
|
|
|
@ -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: ¶meters,
|
||||
resource: resource,
|
||||
xmpp: component,
|
||||
jid: jid,
|
||||
Session: session,
|
||||
|
|
|
@ -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 != "" {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue