aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-06-30 03:10:39 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-06-30 03:10:39 +0300
commit5628a15ac496d72c840a265c3dace720e2547728 (patch)
tree7a4a1c68cb320fc58738bb5da23620b8d790c143 /telegram/handlers.go
parent38ffdb9e4791652b09d59643c8e0b200c2566e1c (diff)
Update the contact nickname when a chat title has changed
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r--telegram/handlers.go17
1 files changed, 17 insertions, 0 deletions
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))
+ }
+}