Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial ACL support #59

Merged
merged 3 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions event/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var TypeMap = map[Type]reflect.Type{
StateCanonicalAlias: reflect.TypeOf(CanonicalAliasEventContent{}),
StateRoomName: reflect.TypeOf(RoomNameEventContent{}),
StateRoomAvatar: reflect.TypeOf(RoomAvatarEventContent{}),
StateServerACL: reflect.TypeOf(ServerACLEventContent{}),
StateTopic: reflect.TypeOf(TopicEventContent{}),
StateTombstone: reflect.TypeOf(TombstoneEventContent{}),
StateCreate: reflect.TypeOf(CreateEventContent{}),
Expand Down
8 changes: 8 additions & 0 deletions event/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ type RoomAvatarEventContent struct {
URL id.ContentURI `json:"url"`
}

// ServerACLEventContent represents the content of a m.room.server_acl state event.
// https://spec.matrix.org/v1.1/client-server-api/#server-access-control-lists-acls-for-rooms
type ServerACLEventContent struct {
Allow []string `json:"allow,omitempty"`
AllowIPLiterals bool `json:"allow_ip_literals"`
Deny []string `json:"deny,omitempty"`
}

// TopicEventContent represents the content of a m.room.topic state event.
// https://matrix.org/docs/spec/client_server/r0.6.0#m-room-topic
type TopicEventContent struct {
Expand Down
7 changes: 4 additions & 3 deletions event/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ func (et *Type) IsCustom() bool {
func (et *Type) GuessClass() TypeClass {
switch et.Type {
case StateAliases.Type, StateCanonicalAlias.Type, StateCreate.Type, StateJoinRules.Type, StateMember.Type,
StatePowerLevels.Type, StateRoomName.Type, StateRoomAvatar.Type, StateTopic.Type, StatePinnedEvents.Type,
StateTombstone.Type, StateEncryption.Type, StateBridge.Type, StateHalfShotBridge.Type, StateSpaceParent.Type,
StateSpaceChild.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:
return StateEventType
case EphemeralEventReceipt.Type, EphemeralEventTyping.Type, EphemeralEventPresence.Type:
return EphemeralEventType
Expand Down Expand Up @@ -175,6 +175,7 @@ var (
StateTopic = Type{"m.room.topic", StateEventType}
StateRoomAvatar = Type{"m.room.avatar", StateEventType}
StatePinnedEvents = Type{"m.room.pinned_events", StateEventType}
StateServerACL = Type{"m.room.server_acl", StateEventType}
StateTombstone = Type{"m.room.tombstone", StateEventType}
StateEncryption = Type{"m.room.encryption", StateEventType}
StateBridge = Type{"m.bridge", StateEventType}
Expand Down