Add event type and content struct for moderation policy lists

This commit is contained in:
qua3k 2022-01-08 09:13:25 -05:00 committed by Tulir Asokan
commit f7a6fd2a8b
3 changed files with 15 additions and 1 deletions

View file

@ -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{}),

View file

@ -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"`
}

View file

@ -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}