Attach resource to presences to prevent unwanted behaviour of some clients

This commit is contained in:
Bohdan Horbeshko 2022-02-08 12:43:51 -05:00
parent 76364388ad
commit 0610479734
3 changed files with 17 additions and 0 deletions

View file

@ -48,6 +48,7 @@ type Client struct {
options []client.Option
me *client.User
resource string
xmpp *xmpp.Component
jid string
Session *persistence.Session
@ -115,8 +116,14 @@ 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,

View file

@ -217,6 +217,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.SPImmed(gateway.SPImmed.Get(oldArgs)),
}
if presenceType != "" {

View file

@ -88,6 +88,9 @@ var SPNickname = args.NewString()
// SPPhoto is a XEP-0153 hash of avatar in vCard
var SPPhoto = args.NewString()
// SPResource is an optional resource
var SPResource = args.NewString()
// SPImmed skips queueing
var SPImmed = args.NewBool(args.Default(true))
@ -95,6 +98,12 @@ func newPresence(bareJid string, to string, args ...args.V) stanza.Presence {
var presenceFrom string
if SPFrom.IsSet(args) {
presenceFrom = SPFrom.Get(args) + "@" + bareJid
if SPResource.IsSet(args) {
resource := SPResource.Get(args)
if resource != "" {
presenceFrom += "/" + resource
}
}
} else {
presenceFrom = bareJid
}