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
Changes from 1 commit
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
Next Next commit
Add initial ACL support
qua3k committed Jan 6, 2022
commit bbae77d64b2c4218a8475d03e965cdfedab1d717
1 change: 1 addition & 0 deletions event/content.go
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ var TypeMap = map[Type]reflect.Type{
StateCanonicalAlias: reflect.TypeOf(CanonicalAliasEventContent{}),
StateRoomName: reflect.TypeOf(RoomNameEventContent{}),
StateRoomAvatar: reflect.TypeOf(RoomAvatarEventContent{}),
StateServerAcls: reflect.TypeOf(ServerAclsEventContent{}),
StateTopic: reflect.TypeOf(TopicEventContent{}),
StateTombstone: reflect.TypeOf(TombstoneEventContent{}),
StateCreate: reflect.TypeOf(CreateEventContent{}),
8 changes: 8 additions & 0 deletions event/state.go
Original file line number Diff line number Diff line change
@@ -29,6 +29,14 @@ type RoomAvatarEventContent struct {
URL id.ContentURI `json:"url"`
}

// ServerAclsEventContent 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 ServerAclsEventContent 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 {
7 changes: 4 additions & 3 deletions event/type.go
Original file line number Diff line number Diff line change
@@ -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, StateServerAcls.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
@@ -175,6 +175,7 @@ var (
StateTopic = Type{"m.room.topic", StateEventType}
StateRoomAvatar = Type{"m.room.avatar", StateEventType}
StatePinnedEvents = Type{"m.room.pinned_events", StateEventType}
StateServerAcls = Type{"m.room.server_acl", StateEventType}
StateTombstone = Type{"m.room.tombstone", StateEventType}
StateEncryption = Type{"m.room.encryption", StateEventType}
StateBridge = Type{"m.bridge", StateEventType}