From 225dbdba4e1fed5814c0a3d1f34a8aedf87fc445 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 22 Mar 2018 22:38:49 +0200 Subject: [PATCH] Use display names in join/leave messages --- ui/view-main.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/view-main.go b/ui/view-main.go index 50a6cdb..1bf98a3 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -430,20 +430,24 @@ func (view *MainView) ProcessMembershipEvent(evt *gomatrix.Event, new bool) (roo room = view.GetRoom(evt.RoomID) if room != nil { membership, _ := evt.Content["membership"].(string) + displayname, _ := evt.Content["displayname"].(string) + if len(displayname) == 0 { + displayname = *evt.StateKey + } var sender, text string if membership == "invite" { sender = "---" - text = fmt.Sprintf("%s invited %s.", evt.Sender, *evt.StateKey) + text = fmt.Sprintf("%s invited %s.", evt.Sender, displayname) } else if membership == "join" { sender = "-->" - text = fmt.Sprintf("%s joined the room.", *evt.StateKey) + text = fmt.Sprintf("%s joined the room.", displayname) } else if membership == "leave" { sender = "<--" if evt.Sender != *evt.StateKey { reason, _ := evt.Content["reason"].(string) - text = fmt.Sprintf("%s kicked %s: %s", evt.Sender, *evt.StateKey, reason) + text = fmt.Sprintf("%s kicked %s: %s", evt.Sender, displayname, reason) } else { - text = fmt.Sprintf("%s left the room.", *evt.StateKey) + text = fmt.Sprintf("%s left the room.", displayname) } } else { room = nil