diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-03-22 22:38:49 +0200 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-03-22 22:38:49 +0200 |
commit | 225dbdba4e1fed5814c0a3d1f34a8aedf87fc445 (patch) | |
tree | 77862140d91e239e38ad294d216735ae1428b0f5 /ui | |
parent | 152b89ed5e6a4a3edbfc40222b4388049a213b82 (diff) |
Use display names in join/leave messages
Diffstat (limited to 'ui')
-rw-r--r-- | ui/view-main.go | 12 |
1 files 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 |