diff options
Diffstat (limited to 'matrix-specification/Events/Room')
| -rw-r--r-- | matrix-specification/Events/Room/AvatarEvent.php | 37 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/CanonicalAliasEvent.php | 39 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/CreateEvent.php | 54 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/GuestAccessEvent.php | 35 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/HistoryVisibilityEvent.php | 35 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/JoinRulesEvent.php | 40 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/MemberEvent.php | 47 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/NameEvent.php | 34 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/PinnedEventsEvent.php | 37 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/PowerLevelsEvent.php | 57 | ||||
| -rw-r--r-- | matrix-specification/Events/Room/TopicEvent.php | 37 |
11 files changed, 452 insertions, 0 deletions
diff --git a/matrix-specification/Events/Room/AvatarEvent.php b/matrix-specification/Events/Room/AvatarEvent.php new file mode 100644 index 0000000..c9e18f2 --- /dev/null +++ b/matrix-specification/Events/Room/AvatarEvent.php @@ -0,0 +1,37 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\Room\AvatarInfo; +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class AvatarEvent extends StateEvent +{ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + ?AvatarInfo $info = null, + ?string $url = null, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + array_filter([ + "info" => $info, + "url" => $url, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_AVATAR, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/CanonicalAliasEvent.php b/matrix-specification/Events/Room/CanonicalAliasEvent.php new file mode 100644 index 0000000..63de661 --- /dev/null +++ b/matrix-specification/Events/Room/CanonicalAliasEvent.php @@ -0,0 +1,39 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class CanonicalAliasEvent extends StateEvent +{ + /** + * @param ?string[] $altAliases + */ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + ?string $alias = null, + ?array $altAliases = null, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + array_filter([ + "alias" => $alias, + "alt_aliases" => $altAliases, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_CANONICAL_ALIAS, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/CreateEvent.php b/matrix-specification/Events/Room/CreateEvent.php new file mode 100644 index 0000000..eccda10 --- /dev/null +++ b/matrix-specification/Events/Room/CreateEvent.php @@ -0,0 +1,54 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\Room\PreviousRoom; +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class CreateEvent extends StateEvent +{ + /** + * @param ?string[] $additionalCreators + */ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + string $roomVersion, + ?array $additionalCreators = null, + ?string $creator = null, + bool $federate = true, + ?PreviousRoom $predecessor = null, + ?string $roomType = null, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + if (intval($roomVersion) <= 10) { + if (empty($creator)) { + throw new \InvalidArgumentException("creator is required in room versions 1 - 10"); + } + } + + parent::__construct( + array_filter([ + "additional_creators" => $additionalCreators, + "creator" => intval($roomVersion) <= 10 ? $creator : $sender, + "m.federate" => $federate, + "predecessor" => $predecessor, + "room_version" => $roomVersion, + "type" => $roomType, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_CREATE, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/GuestAccessEvent.php b/matrix-specification/Events/Room/GuestAccessEvent.php new file mode 100644 index 0000000..a0eeddb --- /dev/null +++ b/matrix-specification/Events/Room/GuestAccessEvent.php @@ -0,0 +1,35 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Enums\RoomGuestAccess; +use Matrix\Events\StateEvent; + +class GuestAccessEvent extends StateEvent +{ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + RoomGuestAccess $guestAccess, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + [ + "guest_access" => $guestAccess, + ], + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_GUEST_ACCESS, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/HistoryVisibilityEvent.php b/matrix-specification/Events/Room/HistoryVisibilityEvent.php new file mode 100644 index 0000000..76672bf --- /dev/null +++ b/matrix-specification/Events/Room/HistoryVisibilityEvent.php @@ -0,0 +1,35 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Enums\RoomHistoryVisibility; +use Matrix\Events\StateEvent; + +class HistoryVisibilityEvent extends StateEvent +{ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + RoomHistoryVisibility $historyVisibility, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + [ + "history_visibility" => $historyVisibility, + ], + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_HISTORY_VISIBILITY, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/JoinRulesEvent.php b/matrix-specification/Events/Room/JoinRulesEvent.php new file mode 100644 index 0000000..337c9d2 --- /dev/null +++ b/matrix-specification/Events/Room/JoinRulesEvent.php @@ -0,0 +1,40 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Enums\RoomJoinRule; +use Matrix\Events\StateEvent; + +class JoinRulesEvent extends StateEvent +{ + /** + * @param ?AllowCondition[] $allow + */ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + RoomJoinRule $joinRule, + ?array $allow = null, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + array_filter([ + "allow" => $allow, + "join_rule" => $joinRule, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_JOIN_RULES, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/MemberEvent.php b/matrix-specification/Events/Room/MemberEvent.php new file mode 100644 index 0000000..0f27289 --- /dev/null +++ b/matrix-specification/Events/Room/MemberEvent.php @@ -0,0 +1,47 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Enums\MembershipState; +use Matrix\Events\StateEvent; + +class MemberEvent extends StateEvent +{ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + string $stateKey, + bool $isDirect, + MembershipState $membership, + ?string $avatarUrl = null, + ?string $displayName = null, + ?string $joinAuthorisedViaUsersServer = null, + ?string $reason = null, + ?object $thirdPartyInvite = null, # TODO: https://spec.matrix.org/v1.17/client-server-api/#mroommember_thirdpartyinvite + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + array_filter([ + "avatar_url" => $avatarUrl, + "displayname" => $displayName, + "is_direct" => $isDirect, + "join_authorised_via_users_server" => $joinAuthorisedViaUsersServer, + "membership" => $membership, + "reason" => $reason, + "third_party_invite" => $thirdPartyInvite, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_MEMBER, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/NameEvent.php b/matrix-specification/Events/Room/NameEvent.php new file mode 100644 index 0000000..187b36a --- /dev/null +++ b/matrix-specification/Events/Room/NameEvent.php @@ -0,0 +1,34 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class NameEvent extends StateEvent +{ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + string $name, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + [ + "name" => $name, + ], + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_NAME, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/PinnedEventsEvent.php b/matrix-specification/Events/Room/PinnedEventsEvent.php new file mode 100644 index 0000000..c0a98b0 --- /dev/null +++ b/matrix-specification/Events/Room/PinnedEventsEvent.php @@ -0,0 +1,37 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class PinnedEventsEvent extends StateEvent +{ + /** + * @param string[] $pinned + */ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + array $pinned, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + [ + "pinned" => $pinned, + ], + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_CANONICAL_ALIAS, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/PowerLevelsEvent.php b/matrix-specification/Events/Room/PowerLevelsEvent.php new file mode 100644 index 0000000..8b609f3 --- /dev/null +++ b/matrix-specification/Events/Room/PowerLevelsEvent.php @@ -0,0 +1,57 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class PowerLevelsEvent extends StateEvent +{ + /** + * @param ?array<string, int> $events This is a mapping from event type to power level required. + * @param ?array<string, int> $notifications This is a mapping from key to power level for that notifications key. + * @param ?array<string, int> $events This is a mapping from user_id to power level for that user. + */ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + ?int $ban = 50, + ?array $events = null, + ?int $eventsDefault = 0, + ?int $invite = 0, + ?int $kick = 50, + ?array $notifications = null, # TODO: https://spec.matrix.org/v1.17/client-server-api/#mroompower_levels_notifications + ?int $redact = 50, + ?int $stateDefault = 50, + ?array $users = null, + ?int $usersDefault = 0, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + array_filter([ + "ban" => $ban, + "events" => $events, + "events_default" => $eventsDefault, + "invite" => $invite, + "kick" => $kick, + "notifications" => $notifications, + "redact" => $redact, + "state_default" => $stateDefault, + "users" => $users, + "users_default" => $usersDefault, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_POWER_LEVELS, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Room/TopicEvent.php b/matrix-specification/Events/Room/TopicEvent.php new file mode 100644 index 0000000..8e01a3b --- /dev/null +++ b/matrix-specification/Events/Room/TopicEvent.php @@ -0,0 +1,37 @@ +<?php + +namespace Matrix\Events\Room; + +use Matrix\Data\Room\TopicContentBlock; +use Matrix\Data\UnsignedData; +use Matrix\Enums\EventType; +use Matrix\Events\StateEvent; + +class TopicEvent extends StateEvent +{ + public function __construct( + string $eventId, + int $originServerTimestamp, + string $roomId, + string $sender, + string $topic, + ?TopicContentBlock $topicContentBlock = null, + string $stateKey = "", + ?UnsignedData $unsigned = null, + ) + { + parent::__construct( + array_filter([ + "m.topic" => $topicContentBlock, + "topic" => $topic, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_TOPIC, + $unsigned, + ); + } +} |
