diff --git a/web/src/ui/timeline/content/PolicyRuleBody.tsx b/web/src/ui/timeline/content/PolicyRuleBody.tsx
index cd2e577..cf69e87 100644
--- a/web/src/ui/timeline/content/PolicyRuleBody.tsx
+++ b/web/src/ui/timeline/content/PolicyRuleBody.tsx
@@ -1,27 +1,57 @@
+// gomuks - A Matrix client written in Go.
+// Copyright (C) 2024 Tulir Asokan
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+import { use } from "react"
import { PolicyRuleContent } from "@/api/types"
+import MainScreenContext from "@/ui/MainScreenContext.ts"
import EventContentProps from "./props.ts"
const BanPolicyBody = ({ event, sender }: EventContentProps) => {
const content = event.content as PolicyRuleContent
const prevContent = event.unsigned.prev_content as PolicyRuleContent | undefined
+ const mainScreen = use(MainScreenContext)
- if (prevContent !== undefined) {
- // all fields for content are missing (this is against spec?) so we need to use the prev event's content
- if (content.entity === undefined) {
- // unban
- return
- {sender?.content.displayname ?? event.sender} Removed the policy rule banning {prevContent.entity}
-
- }
- // update
- return
- {sender?.content.displayname ?? event.sender} Updated a policy rule banning {content.entity} for
- {content.reason}
-
+ let entity = content.entity || prevContent?.entity
+ if(event.type === "m.policy.rule.user" && !content.entity?.includes("*") && !content.entity?.includes("?")) {
+ // Is user policy, and does not include the glob chars * and ?
+ entity = (
+
+ {content.entity}
+
+ )
+ }
+
+ let action = "added"
+ if (prevContent) {
+ if (!content) {
+ // If the content is empty, the ban is revoked.
+ action = "removed"
+ } else {
+ // There is still content, so the policy was updated
+ action = "updated"
+ }
}
- // add
return
- {sender?.content.displayname ?? event.sender} Added a policy rule banning {content.entity} for {content.reason}
+ {sender?.content.displayname ?? event.sender} {action} a policy rule
+ {action === "removed" ? "un" : null}banning {entity} for {content.reason}
}