From bd11271621bd3759cfd194ed0119c0dc28155fd0 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 5 Mar 2026 14:57:28 +0100 Subject: update --- matrix-specification/Data/DeviceLists.php | 4 +- matrix-specification/Data/Room/AllowCondition.php | 24 +++++++++ matrix-specification/Data/Room/AvatarInfo.php | 28 +++++++++++ matrix-specification/Data/Room/JoinedRoom.php | 4 +- matrix-specification/Data/Room/PreviousRoom.php | 20 ++++++++ matrix-specification/Data/Room/Rooms.php | 10 ++-- .../Data/Room/TextualRepresentation.php | 20 ++++++++ matrix-specification/Data/Room/ThumbnailInfo.php | 24 +++++++++ .../Data/Room/TopicContentBlock.php | 21 ++++++++ matrix-specification/Data/UnsignedData.php | 32 ++++++++++++ matrix-specification/Enums/EventType.php | 8 +++ matrix-specification/Enums/MessageFormat.php | 13 +++++ matrix-specification/Enums/MessageType.php | 20 ++++++++ matrix-specification/Enums/RoomGuestAccess.php | 14 ++++++ .../Enums/RoomHistoryVisibility.php | 16 ++++++ matrix-specification/Enums/RoomJoinRule.php | 18 +++++++ matrix-specification/Enums/RoomVisibility.php | 14 ++++++ matrix-specification/Events/ClientEvent.php | 41 ++++++++++++---- .../Events/ClientEventWithoutRoomId.php | 32 ++++++------ matrix-specification/Events/Event.php | 13 +++++ .../Events/Message/FormattedMessageEvent.php | 39 +++++++++++++++ .../Events/Message/MessageEvent.php | 35 +++++++++++++ .../Events/Message/TextMessageEvent.php | 38 +++++++++++++++ matrix-specification/Events/PresenceEvent.php | 9 ---- matrix-specification/Events/Room/AvatarEvent.php | 37 ++++++++++++++ .../Events/Room/CanonicalAliasEvent.php | 39 +++++++++++++++ matrix-specification/Events/Room/CreateEvent.php | 54 ++++++++++++++++++++ .../Events/Room/GuestAccessEvent.php | 35 +++++++++++++ .../Events/Room/HistoryVisibilityEvent.php | 35 +++++++++++++ .../Events/Room/JoinRulesEvent.php | 40 +++++++++++++++ matrix-specification/Events/Room/MemberEvent.php | 47 ++++++++++++++++++ matrix-specification/Events/Room/NameEvent.php | 34 +++++++++++++ .../Events/Room/PinnedEventsEvent.php | 37 ++++++++++++++ .../Events/Room/PowerLevelsEvent.php | 57 ++++++++++++++++++++++ matrix-specification/Events/Room/TopicEvent.php | 37 ++++++++++++++ matrix-specification/Events/SenderEvent.php | 14 ++++++ matrix-specification/Events/StateEvent.php | 50 +++++++++++++++++++ matrix-specification/Events/StrippedStateEvent.php | 4 +- matrix-specification/Events/UnsignedData.php | 31 ------------ .../Responses/ClientKeysUploadPostResponse.php | 2 +- 40 files changed, 974 insertions(+), 76 deletions(-) create mode 100644 matrix-specification/Data/Room/AllowCondition.php create mode 100644 matrix-specification/Data/Room/AvatarInfo.php create mode 100644 matrix-specification/Data/Room/PreviousRoom.php create mode 100644 matrix-specification/Data/Room/TextualRepresentation.php create mode 100644 matrix-specification/Data/Room/ThumbnailInfo.php create mode 100644 matrix-specification/Data/Room/TopicContentBlock.php create mode 100644 matrix-specification/Data/UnsignedData.php create mode 100644 matrix-specification/Enums/MessageFormat.php create mode 100644 matrix-specification/Enums/MessageType.php create mode 100644 matrix-specification/Enums/RoomGuestAccess.php create mode 100644 matrix-specification/Enums/RoomHistoryVisibility.php create mode 100644 matrix-specification/Enums/RoomJoinRule.php create mode 100644 matrix-specification/Enums/RoomVisibility.php create mode 100644 matrix-specification/Events/Message/FormattedMessageEvent.php create mode 100644 matrix-specification/Events/Message/MessageEvent.php create mode 100644 matrix-specification/Events/Message/TextMessageEvent.php create mode 100644 matrix-specification/Events/Room/AvatarEvent.php create mode 100644 matrix-specification/Events/Room/CanonicalAliasEvent.php create mode 100644 matrix-specification/Events/Room/CreateEvent.php create mode 100644 matrix-specification/Events/Room/GuestAccessEvent.php create mode 100644 matrix-specification/Events/Room/HistoryVisibilityEvent.php create mode 100644 matrix-specification/Events/Room/JoinRulesEvent.php create mode 100644 matrix-specification/Events/Room/MemberEvent.php create mode 100644 matrix-specification/Events/Room/NameEvent.php create mode 100644 matrix-specification/Events/Room/PinnedEventsEvent.php create mode 100644 matrix-specification/Events/Room/PowerLevelsEvent.php create mode 100644 matrix-specification/Events/Room/TopicEvent.php create mode 100644 matrix-specification/Events/StateEvent.php delete mode 100644 matrix-specification/Events/UnsignedData.php (limited to 'matrix-specification') diff --git a/matrix-specification/Data/DeviceLists.php b/matrix-specification/Data/DeviceLists.php index 33d9459..eef2df4 100644 --- a/matrix-specification/Data/DeviceLists.php +++ b/matrix-specification/Data/DeviceLists.php @@ -17,8 +17,8 @@ class DeviceLists implements \JsonSerializable public function jsonSerialize(): array { return [ - "changed" => $this->events, - "left" => $this->events, + "changed" => $this->changed, + "left" => $this->left, ]; } } diff --git a/matrix-specification/Data/Room/AllowCondition.php b/matrix-specification/Data/Room/AllowCondition.php new file mode 100644 index 0000000..600c618 --- /dev/null +++ b/matrix-specification/Data/Room/AllowCondition.php @@ -0,0 +1,24 @@ + $this->roomId, + "type" => $this->type, + ], fn ($value) => ! is_null($value)); + } +} diff --git a/matrix-specification/Data/Room/AvatarInfo.php b/matrix-specification/Data/Room/AvatarInfo.php new file mode 100644 index 0000000..473beb9 --- /dev/null +++ b/matrix-specification/Data/Room/AvatarInfo.php @@ -0,0 +1,28 @@ + $this->height, + "mimetype" => $this->mimeType, + "size" => $this->fileSize, + "thumbnail_info" => $this->thumbnailInfo, + "thumbnail_url" => $this->thumbnailUrl, + "w" => $this->width, + ]; + } +} diff --git a/matrix-specification/Data/Room/JoinedRoom.php b/matrix-specification/Data/Room/JoinedRoom.php index 0057071..f78eaea 100644 --- a/matrix-specification/Data/Room/JoinedRoom.php +++ b/matrix-specification/Data/Room/JoinedRoom.php @@ -24,14 +24,14 @@ class JoinedRoom implements \JsonSerializable public function jsonSerialize(): array { return array_filter([ - "account_data" => $this->inviteState, + "account_data" => $this->accountData, "ephemeral" => $this->ephemeral, "state" => $this->state, "state_after" => $this->stateAfter, "summary" => $this->summary, "timeline" => $this->timeline, "unread_notifications" => $this->unreadNotifications, - "unreadThreadNotifications" => $this->unreadThreadNotifications, + "unreadThreadNotifications" => empty($this->unreadThreadNotifications) ? new \stdClass() : $this->unreadNotifications, ], fn ($value) => ! is_null($value)); } } diff --git a/matrix-specification/Data/Room/PreviousRoom.php b/matrix-specification/Data/Room/PreviousRoom.php new file mode 100644 index 0000000..ced4172 --- /dev/null +++ b/matrix-specification/Data/Room/PreviousRoom.php @@ -0,0 +1,20 @@ + $this->eventId, + "room_id" => $this->roomId, + ], fn ($value) => ! is_null($value)); + } +} diff --git a/matrix-specification/Data/Room/Rooms.php b/matrix-specification/Data/Room/Rooms.php index 1a84608..4d2cdf6 100644 --- a/matrix-specification/Data/Room/Rooms.php +++ b/matrix-specification/Data/Room/Rooms.php @@ -21,17 +21,17 @@ class Rooms implements \JsonSerializable public function jsonSerialize(): array { return [ - "invite" => $this->invite ?? new \stdClass(), - "join" => $this->join ?? new \stdClass(), - "knock" => $this->knock ?? new \stdClass(), - "leave" => $this->leave ?? new \stdClass(), + "invite" => empty($this->invite) ? new \stdClass() : $this->invite, + "join" => empty($this->join) ? new \stdClass() : $this->join, + "knock" => empty($this->knock) ? new \stdClass() : $this->knock, + "leave" => empty($this->leave) ? new \stdClass() : $this->leave, ]; } /** * @return InvitedRoom[] */ - public function getInvite(): ?array + public function getInvited(): ?array { return $this->invite; } diff --git a/matrix-specification/Data/Room/TextualRepresentation.php b/matrix-specification/Data/Room/TextualRepresentation.php new file mode 100644 index 0000000..9b66f48 --- /dev/null +++ b/matrix-specification/Data/Room/TextualRepresentation.php @@ -0,0 +1,20 @@ + $this->body, + "mimetype" => $this->mimeType, + ], fn ($value) => ! is_null($value)); + } +} diff --git a/matrix-specification/Data/Room/ThumbnailInfo.php b/matrix-specification/Data/Room/ThumbnailInfo.php new file mode 100644 index 0000000..31a264b --- /dev/null +++ b/matrix-specification/Data/Room/ThumbnailInfo.php @@ -0,0 +1,24 @@ + $this->height, + "mimetype" => $this->mimeType, + "size" => $this->fileSize, + "w" => $this->width, + ]; + } +} diff --git a/matrix-specification/Data/Room/TopicContentBlock.php b/matrix-specification/Data/Room/TopicContentBlock.php new file mode 100644 index 0000000..96341d0 --- /dev/null +++ b/matrix-specification/Data/Room/TopicContentBlock.php @@ -0,0 +1,21 @@ + $this->text, + ]; + } +} diff --git a/matrix-specification/Data/UnsignedData.php b/matrix-specification/Data/UnsignedData.php new file mode 100644 index 0000000..a1748cf --- /dev/null +++ b/matrix-specification/Data/UnsignedData.php @@ -0,0 +1,32 @@ + $this->age, + "membership" => $this->membership, + "prev_content" => $this->previousContent, + "redacted_because" => $this->redactedBecause, + "transaction_id" => $this->transactionId, + ], fn ($value) => ! is_null($value)); + } +} diff --git a/matrix-specification/Enums/EventType.php b/matrix-specification/Enums/EventType.php index da199dd..5e2329f 100644 --- a/matrix-specification/Enums/EventType.php +++ b/matrix-specification/Enums/EventType.php @@ -7,9 +7,17 @@ enum EventType: string implements \JsonSerializable case PRESENCE = "m.presence"; case RECEIPT = "m.receipt"; + case ROOM_AVATAR = "m.room.avatar"; + case ROOM_CANONICAL_ALIAS = "m.room.canonical_alias"; + case ROOM_CREATE = "m.room.create"; + case ROOM_GUEST_ACCESS = "m.room.guest_access"; + case ROOM_HISTORY_VISIBILITY = "m.room.history_visibility"; + case ROOM_JOIN_RULES = "m.room.join_rules"; case ROOM_MEMBER = "m.room.member"; case ROOM_MESSAGE = "m.room.message"; case ROOM_NAME = "m.room.name"; + case ROOM_POWER_LEVELS = "m.room.power_levels"; + case ROOM_TOPIC = "m.room.topic"; case TAG = "m.tag"; case TYPING = "m.typing"; diff --git a/matrix-specification/Enums/MessageFormat.php b/matrix-specification/Enums/MessageFormat.php new file mode 100644 index 0000000..eb543a0 --- /dev/null +++ b/matrix-specification/Enums/MessageFormat.php @@ -0,0 +1,13 @@ +value; + } +} diff --git a/matrix-specification/Enums/MessageType.php b/matrix-specification/Enums/MessageType.php new file mode 100644 index 0000000..eefd86b --- /dev/null +++ b/matrix-specification/Enums/MessageType.php @@ -0,0 +1,20 @@ +value; + } +} diff --git a/matrix-specification/Enums/RoomGuestAccess.php b/matrix-specification/Enums/RoomGuestAccess.php new file mode 100644 index 0000000..1c7a14b --- /dev/null +++ b/matrix-specification/Enums/RoomGuestAccess.php @@ -0,0 +1,14 @@ +value; + } +} diff --git a/matrix-specification/Enums/RoomHistoryVisibility.php b/matrix-specification/Enums/RoomHistoryVisibility.php new file mode 100644 index 0000000..6477ef4 --- /dev/null +++ b/matrix-specification/Enums/RoomHistoryVisibility.php @@ -0,0 +1,16 @@ +value; + } +} diff --git a/matrix-specification/Enums/RoomJoinRule.php b/matrix-specification/Enums/RoomJoinRule.php new file mode 100644 index 0000000..6926227 --- /dev/null +++ b/matrix-specification/Enums/RoomJoinRule.php @@ -0,0 +1,18 @@ +value; + } +} diff --git a/matrix-specification/Enums/RoomVisibility.php b/matrix-specification/Enums/RoomVisibility.php new file mode 100644 index 0000000..3b03b0c --- /dev/null +++ b/matrix-specification/Enums/RoomVisibility.php @@ -0,0 +1,14 @@ +value; + } +} diff --git a/matrix-specification/Events/ClientEvent.php b/matrix-specification/Events/ClientEvent.php index be1e354..dda4ead 100644 --- a/matrix-specification/Events/ClientEvent.php +++ b/matrix-specification/Events/ClientEvent.php @@ -2,31 +2,54 @@ namespace Matrix\Events; +use Matrix\Data\UnsignedData; use Matrix\Enums\EventType; -class ClientEvent extends ClientEventWithoutRoomId +class ClientEvent extends SenderEvent { public function __construct( array $content, - string $eventId, - int $originServerTimestamp, + protected string $eventId, + protected int $originServerTimestamp, protected string $roomId, string $sender, - string $stateKey, EventType $type, - ?UnsignedData $unsigned = null, + protected ?UnsignedData $unsigned = null, ) { - parent::__construct($content, $eventId, $originServerTimestamp, $sender, $stateKey, $type); + parent::__construct($content, $sender, $type); } public function jsonSerialize(): array { - $clientEvent = parent::jsonSerialize(); - $clientEvent += [ + return [ + "content" => $this->content ?: new \stdClass, + "event_id" => $this->eventId, + "origin_server_ts" => $this->originServerTimestamp, "room_id" => $this->roomId, + "sender" => $this->sender, + "type" => $this->type, + "unsigned" => $this->unsigned ?? new \stdClass, ]; + } + + public function getId(): string + { + return $this->eventId; + } - return $clientEvent; + public function getOriginServerTimestamp(): int + { + return $this->originServerTimestamp; + } + + public function getRoomId(): string + { + return $this->roomId; + } + + public function getUnsigned(): ?UnsignedData + { + return $this->unsigned; } } diff --git a/matrix-specification/Events/ClientEventWithoutRoomId.php b/matrix-specification/Events/ClientEventWithoutRoomId.php index 0410d5b..f10d125 100644 --- a/matrix-specification/Events/ClientEventWithoutRoomId.php +++ b/matrix-specification/Events/ClientEventWithoutRoomId.php @@ -4,31 +4,33 @@ namespace Matrix\Events; use Matrix\Enums\EventType; -class ClientEventWithoutRoomId extends SenderEvent +class ClientEventWithoutRoomId extends ClientEvent { public function __construct( array $content, - protected string $eventId, - protected int $originServerTimestamp, + string $eventId, + int $originServerTimestamp, string $sender, - protected string $stateKey, EventType $type, - protected ?UnsignedData $unsigned = null, + ?UnsignedData $unsigned = null, ) { - parent::__construct($content, $sender, $type); + parent::__construct( + $content, + $eventId, + $originServerTimestamp, + "", + $sender, + $type, + $unsigned, + ); } public function jsonSerialize(): array { - return [ - "content" => $this->content ?: new \stdClass, - "event_id" => $this->eventId, - "origin_server_ts" => $this->originServerTimestamp, - "sender" => $this->sender, - "state_key" => $this->stateKey, - "type" => $this->type, - "unsigned" => $this->unsigned ?? new \stdClass, - ]; + $clientEvent = parent::jsonSerialize(); + unset($clientEvent["room_id"]); + + return $clientEvent; } } diff --git a/matrix-specification/Events/Event.php b/matrix-specification/Events/Event.php index fe85f48..5b3e450 100644 --- a/matrix-specification/Events/Event.php +++ b/matrix-specification/Events/Event.php @@ -14,4 +14,17 @@ abstract class Event implements \JsonSerializable protected EventType $type, ) {} + + /** + * @return array + */ + public function getContent(): array + { + return $this->content; + } + + public function getType(): EventType + { + return $this->type; + } } diff --git a/matrix-specification/Events/Message/FormattedMessageEvent.php b/matrix-specification/Events/Message/FormattedMessageEvent.php new file mode 100644 index 0000000..92e73a1 --- /dev/null +++ b/matrix-specification/Events/Message/FormattedMessageEvent.php @@ -0,0 +1,39 @@ + $body, + "format" => $format, + "formatted_body" => $formattedBody, + "msgtype" => $msgtype, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + EventType::ROOM_MESSAGE, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Message/MessageEvent.php b/matrix-specification/Events/Message/MessageEvent.php new file mode 100644 index 0000000..c06475b --- /dev/null +++ b/matrix-specification/Events/Message/MessageEvent.php @@ -0,0 +1,35 @@ + $body, + "msgtype" => $msgtype, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + EventType::ROOM_MESSAGE, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/Message/TextMessageEvent.php b/matrix-specification/Events/Message/TextMessageEvent.php new file mode 100644 index 0000000..f51317e --- /dev/null +++ b/matrix-specification/Events/Message/TextMessageEvent.php @@ -0,0 +1,38 @@ + $body, + "format" => $format, + "formatted_body" => $formattedBody, + "msgtype" => MessageType::TEXT, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + EventType::ROOM_MESSAGE, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/PresenceEvent.php b/matrix-specification/Events/PresenceEvent.php index 7854444..da40af4 100644 --- a/matrix-specification/Events/PresenceEvent.php +++ b/matrix-specification/Events/PresenceEvent.php @@ -30,13 +30,4 @@ class PresenceEvent extends SenderEvent EventType::PRESENCE ); } - - public function jsonSerialize(): array - { - return [ - "content" => $this->content, - "sender" => $this->sender, - "type" => $this->type, - ]; - } } 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 @@ + $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 @@ + $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 @@ + $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 @@ + $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 @@ + $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 @@ + $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 @@ + $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 @@ + $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 @@ + $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 @@ + $events This is a mapping from event type to power level required. + * @param ?array $notifications This is a mapping from key to power level for that notifications key. + * @param ?array $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 @@ + $topicContentBlock, + "topic" => $topic, + ], fn ($value) => ! is_null($value)), + $eventId, + $originServerTimestamp, + $roomId, + $sender, + $stateKey, + EventType::ROOM_TOPIC, + $unsigned, + ); + } +} diff --git a/matrix-specification/Events/SenderEvent.php b/matrix-specification/Events/SenderEvent.php index f3d4ceb..86ba65e 100644 --- a/matrix-specification/Events/SenderEvent.php +++ b/matrix-specification/Events/SenderEvent.php @@ -17,4 +17,18 @@ abstract class SenderEvent extends Event { parent::__construct($content, $type); } + + public function jsonSerialize(): array + { + return [ + "content" => $this->content, + "sender" => $this->sender, + "type" => $this->type, + ]; + } + + public function getSender(): string + { + return $this->sender; + } } diff --git a/matrix-specification/Events/StateEvent.php b/matrix-specification/Events/StateEvent.php new file mode 100644 index 0000000..7fe7c83 --- /dev/null +++ b/matrix-specification/Events/StateEvent.php @@ -0,0 +1,50 @@ + $this->content ?: new \stdClass, + "event_id" => $this->eventId, + "origin_server_ts" => $this->originServerTimestamp, + "room_id" => $this->roomId, + "sender" => $this->sender, + "state_key" => $this->stateKey, + "type" => $this->type, + "unsigned" => $this->unsigned ?? new \stdClass, + ]; + } + + public function getStateKey(): string + { + return $this->stateKey; + } +} diff --git a/matrix-specification/Events/StrippedStateEvent.php b/matrix-specification/Events/StrippedStateEvent.php index 6e8aea6..3eea582 100644 --- a/matrix-specification/Events/StrippedStateEvent.php +++ b/matrix-specification/Events/StrippedStateEvent.php @@ -12,11 +12,11 @@ class StrippedStateEvent extends SenderEvent public function __construct( array $content, string $sender, - private string $stateKey, + protected string $stateKey, EventType $type, ) { - parent::__construct($content, $sender, $type); + parent::__construct($content, $type); } public function jsonSerialize(): array diff --git a/matrix-specification/Events/UnsignedData.php b/matrix-specification/Events/UnsignedData.php deleted file mode 100644 index 3c5cd46..0000000 --- a/matrix-specification/Events/UnsignedData.php +++ /dev/null @@ -1,31 +0,0 @@ - $this->age, - "membership" => $this->membership, - "prev_content" => $this->previousContent, - "redacted_because" => $this->redactedBecause, - "transaction_id" => $this->transactionId, - ], fn ($value) => ! is_null($value)); - } -} diff --git a/matrix-specification/Responses/ClientKeysUploadPostResponse.php b/matrix-specification/Responses/ClientKeysUploadPostResponse.php index 3d335e4..1df917a 100644 --- a/matrix-specification/Responses/ClientKeysUploadPostResponse.php +++ b/matrix-specification/Responses/ClientKeysUploadPostResponse.php @@ -20,7 +20,7 @@ class ClientKeysUploadPostResponse extends Response public function getBody(): array { return [ - "one_time_keys_counts" => $this->oneTimeKeyCounts, + "one_time_key_counts" => $this->oneTimeKeyCounts, ]; } } -- cgit v1.2.3