Fix membership event processing
This commit is contained in:
parent
a5e7ca227c
commit
7cc55ade30
@ -404,14 +404,22 @@ func (view *MainView) getMembershipEventContent(evt *gomatrix.Event) (sender, te
|
||||
if len(displayname) == 0 {
|
||||
displayname = *evt.StateKey
|
||||
}
|
||||
prevMembership := "leave"
|
||||
prevDisplayname := ""
|
||||
if evt.Unsigned.PrevContent != nil {
|
||||
prevMembership, _ = evt.Unsigned.PrevContent["membership"].(string)
|
||||
prevDisplayname, _ = evt.Unsigned.PrevContent["displayname"].(string)
|
||||
}
|
||||
|
||||
if membership == "invite" {
|
||||
if membership != prevMembership {
|
||||
switch membership {
|
||||
case "invite":
|
||||
sender = "---"
|
||||
text = fmt.Sprintf("%s invited %s.", evt.Sender, displayname)
|
||||
} else if membership == "join" {
|
||||
case "join":
|
||||
sender = "-->"
|
||||
text = fmt.Sprintf("%s joined the room.", displayname)
|
||||
} else if membership == "leave" {
|
||||
case "leave":
|
||||
sender = "<--"
|
||||
if evt.Sender != *evt.StateKey {
|
||||
reason, _ := evt.Content["reason"].(string)
|
||||
@ -420,6 +428,10 @@ func (view *MainView) getMembershipEventContent(evt *gomatrix.Event) (sender, te
|
||||
text = fmt.Sprintf("%s left the room.", displayname)
|
||||
}
|
||||
}
|
||||
} else if displayname != prevDisplayname {
|
||||
sender = "---"
|
||||
text = fmt.Sprintf("%s changed their display name to %s.", prevDisplayname, displayname)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user