aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-15 18:02:36 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-15 18:02:36 +0300
commitfdbb168e2bd4ba6eca864a41c0d1906669fb5fbe (patch)
treec5b1baf5516953f79fba2e73854cb9cb43a5d674
parent709a57d029e6d6728cd9a021a1113b5bb2315b3f (diff)
Display ban/unban events
-rw-r--r--matrix/rooms/member.go1
-rw-r--r--ui/messages/parser/parser.go16
2 files changed, 14 insertions, 3 deletions
diff --git a/matrix/rooms/member.go b/matrix/rooms/member.go
index 0f7133a..aee7533 100644
--- a/matrix/rooms/member.go
+++ b/matrix/rooms/member.go
@@ -28,6 +28,7 @@ const (
MembershipJoin Membership = "join"
MembershipLeave Membership = "leave"
MembershipInvite Membership = "invite"
+ MembershipBan Membership = "ban"
MembershipKnock Membership = "knock"
)
diff --git a/ui/messages/parser/parser.go b/ui/messages/parser/parser.go
index 0c250da..647b931 100644
--- a/ui/messages/parser/parser.go
+++ b/ui/messages/parser/parser.go
@@ -115,10 +115,15 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st
case "leave":
sender = "<--"
if evt.Sender != *evt.StateKey {
- reason, _ := evt.Content["reason"].(string)
- text = tstring.NewColorTString(fmt.Sprintf("%s kicked %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed)
+ if prevMembership == "ban" {
+ text = tstring.NewColorTString(fmt.Sprintf("%s unbanned %s", senderDisplayname, displayname), tcell.ColorGreen)
+ text.Colorize(len(senderDisplayname)+len(" unbanned "), len(displayname), widget.GetHashColor(*evt.StateKey))
+ } else {
+ reason, _ := evt.Content["reason"].(string)
+ text = tstring.NewColorTString(fmt.Sprintf("%s kicked %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed)
+ text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey))
+ }
text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender))
- text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey))
} else {
if displayname == *evt.StateKey {
displayname = prevDisplayname
@@ -126,6 +131,11 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st
text = tstring.NewColorTString(fmt.Sprintf("%s left the room.", displayname), tcell.ColorRed)
text.Colorize(0, len(displayname), widget.GetHashColor(*evt.StateKey))
}
+ case "ban":
+ reason, _ := evt.Content["reason"].(string)
+ text = tstring.NewColorTString(fmt.Sprintf("%s banned %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed)
+ text.Colorize(len(senderDisplayname)+len(" banned "), len(displayname), widget.GetHashColor(*evt.StateKey))
+ text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender))
}
} else if displayname != prevDisplayname {
sender = "---"