From 30b3fd16153fab727315f014150d98b367ccd6ad Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Fri, 30 Jun 2023 09:54:39 -0400 Subject: [PATCH] Force update nicknames via PubSub and presences on reconnect --- telegram/utils.go | 15 +++++++++++++++ xmpp/handlers.go | 1 + 2 files changed, 16 insertions(+) diff --git a/telegram/utils.go b/telegram/utils.go index 58f7712..a9e0bc8 100644 --- a/telegram/utils.go +++ b/telegram/utils.go @@ -1332,3 +1332,18 @@ func (c *Client) GetVcardInfo(toID int64) (VCardInfo, error) { return info, nil } + +func (c *Client) UpdateChatNicknames() { + for _, id := range c.cache.ChatsKeys() { + chat, ok := c.cache.GetChat(id) + if ok { + gateway.SendPresence( + c.xmpp, + c.jid, + gateway.SPFrom(strconv.FormatInt(id, 10)), + gateway.SPNickname(chat.Title), + ) + gateway.SetNickname(c.jid, strconv.FormatInt(id, 10), chat.Title, c.xmpp) + } + } +} diff --git a/xmpp/handlers.go b/xmpp/handlers.go index d5666b1..1286914 100644 --- a/xmpp/handlers.go +++ b/xmpp/handlers.go @@ -342,6 +342,7 @@ func handlePresence(s xmpp.Sender, p stanza.Presence) { gateway.SPImmed(false), ) } + session.UpdateChatNicknames() } }() }