Use display names in join/leave messages
This commit is contained in:
parent
152b89ed5e
commit
225dbdba4e
@ -430,20 +430,24 @@ func (view *MainView) ProcessMembershipEvent(evt *gomatrix.Event, new bool) (roo
|
|||||||
room = view.GetRoom(evt.RoomID)
|
room = view.GetRoom(evt.RoomID)
|
||||||
if room != nil {
|
if room != nil {
|
||||||
membership, _ := evt.Content["membership"].(string)
|
membership, _ := evt.Content["membership"].(string)
|
||||||
|
displayname, _ := evt.Content["displayname"].(string)
|
||||||
|
if len(displayname) == 0 {
|
||||||
|
displayname = *evt.StateKey
|
||||||
|
}
|
||||||
var sender, text string
|
var sender, text string
|
||||||
if membership == "invite" {
|
if membership == "invite" {
|
||||||
sender = "---"
|
sender = "---"
|
||||||
text = fmt.Sprintf("%s invited %s.", evt.Sender, *evt.StateKey)
|
text = fmt.Sprintf("%s invited %s.", evt.Sender, displayname)
|
||||||
} else if membership == "join" {
|
} else if membership == "join" {
|
||||||
sender = "-->"
|
sender = "-->"
|
||||||
text = fmt.Sprintf("%s joined the room.", *evt.StateKey)
|
text = fmt.Sprintf("%s joined the room.", displayname)
|
||||||
} else if membership == "leave" {
|
} else if membership == "leave" {
|
||||||
sender = "<--"
|
sender = "<--"
|
||||||
if evt.Sender != *evt.StateKey {
|
if evt.Sender != *evt.StateKey {
|
||||||
reason, _ := evt.Content["reason"].(string)
|
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 {
|
} else {
|
||||||
text = fmt.Sprintf("%s left the room.", *evt.StateKey)
|
text = fmt.Sprintf("%s left the room.", displayname)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
room = nil
|
room = nil
|
||||||
|
Loading…
Reference in New Issue
Block a user