From 5628a15ac496d72c840a265c3dace720e2547728 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Wed, 29 Jun 2022 20:10:39 -0400 Subject: Update the contact nickname when a chat title has changed --- telegram/handlers.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'telegram') diff --git a/telegram/handlers.go b/telegram/handlers.go index 919c173..126d858 100644 --- a/telegram/handlers.go +++ b/telegram/handlers.go @@ -135,6 +135,12 @@ func (c *Client) updateHandler() { uhOh() } c.updateMessageSendFailed(typedUpdate) + case client.TypeUpdateChatTitle: + typedUpdate, ok := update.(*client.UpdateChatTitle) + if !ok { + uhOh() + } + c.updateChatTitle(typedUpdate) default: // log only handled types continue @@ -277,3 +283,14 @@ func (c *Client) updateMessageSendFailed(update *client.UpdateMessageSendFailed) c.cleanTempFile(file.Local.Path) } } + +// chat title changed +func (c *Client) updateChatTitle(update *client.UpdateChatTitle) { + gateway.SetNickname(c.jid, strconv.FormatInt(update.ChatId, 10), update.Title, c.xmpp) + + // set also the status (for group chats only) + _, user, _ := c.GetContactByID(update.ChatId, nil) + if user == nil { + c.ProcessStatusUpdate(update.ChatId, update.Title, "chat", gateway.SPImmed(true)) + } +} -- cgit v1.2.3