From f7a6fd2a8b3372e6bfac3077da71ca9e6b9ddc8a Mon Sep 17 00:00:00 2001 From: qua3k Date: Sat, 8 Jan 2022 09:13:25 -0500 Subject: [PATCH] Add event type and content struct for moderation policy lists --- event/content.go | 3 +++ event/state.go | 8 ++++++++ event/type.go | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/event/content.go b/event/content.go index 6bf05ed3..78a0867e 100644 --- a/event/content.go +++ b/event/content.go @@ -30,6 +30,9 @@ var TypeMap = map[Type]reflect.Type{ StateHistoryVisibility: reflect.TypeOf(HistoryVisibilityEventContent{}), StateGuestAccess: reflect.TypeOf(GuestAccessEventContent{}), StatePinnedEvents: reflect.TypeOf(PinnedEventsEventContent{}), + StatePolicyRoom: reflect.TypeOf(ModPolicyContent{}), + StatePolicyServer: reflect.TypeOf(ModPolicyContent{}), + StatePolicyUser: reflect.TypeOf(ModPolicyContent{}), StateEncryption: reflect.TypeOf(EncryptionEventContent{}), StateBridge: reflect.TypeOf(BridgeEventContent{}), StateHalfShotBridge: reflect.TypeOf(BridgeEventContent{}), diff --git a/event/state.go b/event/state.go index e72b9a38..e62b592c 100644 --- a/event/state.go +++ b/event/state.go @@ -144,3 +144,11 @@ type SpaceParentEventContent struct { Via []string `json:"via,omitempty"` Canonical bool `json:"canonical,omitempty"` } + +// ModPolicyContent represents the content of a m.room.rule.user, m.room.rule.room, and m.room.rule.server state event. +// https://spec.matrix.org/v1.1/client-server-api/#moderation-policy-lists +type ModPolicyContent struct { + Entity string `json:"entity"` + Reason string `json:"reason"` + Recommendation string `json:"recommendation"` +} diff --git a/event/type.go b/event/type.go index f1af8b88..4ed40f20 100644 --- a/event/type.go +++ b/event/type.go @@ -109,7 +109,7 @@ func (et *Type) GuessClass() TypeClass { case StateAliases.Type, StateCanonicalAlias.Type, StateCreate.Type, StateJoinRules.Type, StateMember.Type, StatePowerLevels.Type, StateRoomName.Type, StateRoomAvatar.Type, StateServerACL.Type, StateTopic.Type, StatePinnedEvents.Type, StateTombstone.Type, StateEncryption.Type, StateBridge.Type, StateHalfShotBridge.Type, - StateSpaceParent.Type, StateSpaceChild.Type: + StateSpaceParent.Type, StateSpaceChild.Type, StatePolicyRoom.Type, StatePolicyServer.Type, StatePolicyUser.Type: return StateEventType case EphemeralEventReceipt.Type, EphemeralEventTyping.Type, EphemeralEventPresence.Type: return EphemeralEventType @@ -177,6 +177,9 @@ var ( StatePinnedEvents = Type{"m.room.pinned_events", StateEventType} StateServerACL = Type{"m.room.server_acl", StateEventType} StateTombstone = Type{"m.room.tombstone", StateEventType} + StatePolicyRoom = Type{"m.policy.rule.room", StateEventType} + StatePolicyServer = Type{"m.policy.rule.server", StateEventType} + StatePolicyUser = Type{"m.policy.rule.user", StateEventType} StateEncryption = Type{"m.room.encryption", StateEventType} StateBridge = Type{"m.bridge", StateEventType} StateHalfShotBridge = Type{"uk.half-shot.bridge", StateEventType}