From b19a8f63ad727a3633885d3f2b81edf8181a53b9 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 25 Sep 2025 13:38:24 +0200 Subject: matrix-specification split work in progress --- matrix-specification/AccountData.php | 16 ------ matrix-specification/Data/AccountData.php | 23 ++++++++ matrix-specification/Data/Contact.php | 28 ++++++++++ matrix-specification/Data/DeviceKeys.php | 31 +++++++++++ matrix-specification/Data/DeviceLists.php | 24 +++++++++ matrix-specification/Data/DiscoveryInformation.php | 30 +++++++++++ matrix-specification/Data/Filters/EventFilter.php | 36 +++++++++++++ .../Data/Filters/RoomEventFilter.php | 50 +++++++++++++++++ matrix-specification/Data/Filters/RoomFilter.php | 39 ++++++++++++++ .../Data/HomeServerInformation.php | 18 +++++++ .../Data/IdentityServerInformation.php | 18 +++++++ matrix-specification/Data/KeyObject.php | 32 +++++++++++ matrix-specification/Data/LoginFlow.php | 31 +++++++++++ matrix-specification/Data/Presence.php | 23 ++++++++ matrix-specification/Data/Room/Ephemeral.php | 21 ++++++++ matrix-specification/Data/Room/InviteState.php | 23 ++++++++ matrix-specification/Data/Room/InvitedRoom.php | 18 +++++++ matrix-specification/Data/Room/JoinedRoom.php | 37 +++++++++++++ matrix-specification/Data/Room/KnockState.php | 23 ++++++++ matrix-specification/Data/Room/KnockedRoom.php | 18 +++++++ matrix-specification/Data/Room/LeftRoom.php | 30 +++++++++++ matrix-specification/Data/Room/RoomSummary.php | 25 +++++++++ matrix-specification/Data/Room/Rooms.php | 62 ++++++++++++++++++++++ matrix-specification/Data/Room/State.php | 23 ++++++++ .../Data/Room/ThreadNotificationCounts.php | 20 +++++++ matrix-specification/Data/Room/Timeline.php | 27 ++++++++++ .../Data/Room/UnreadNotificationCounts.php | 20 +++++++ matrix-specification/Data/ToDevice.php | 23 ++++++++ matrix-specification/Data/UserId.php | 17 ++++++ matrix-specification/Data/UserIdentifier.php | 45 ++++++++++++++++ matrix-specification/Enums/ApiPathVersion.php | 11 ++++ matrix-specification/Enums/EventType.php | 4 ++ matrix-specification/Enums/Role.php | 14 +++++ matrix-specification/Events/PresenceEvent.php | 14 ++--- matrix-specification/Events/StrippedStateEvent.php | 31 +++++++++++ matrix-specification/Request.php | 26 +++++++++ .../ClientDirectoryRoomAliasGetRequest.php | 29 ++++++++++ .../Requests/ClientKeysUploadPostRequest.php | 29 ++++++++++ .../Requests/ClientLoginGetRequest.php | 6 --- .../Requests/ClientLoginPostRequest.php | 2 +- .../Requests/ClientRefreshPostRequest.php | 18 +++++++ .../Requests/ClientSyncGetRequest.php | 34 +++++++++++- .../Requests/ClientUserIdFilterPostRequest.php | 34 ++++++++++++ .../Requests/RequiresAuthentication.php | 2 +- .../Responses/ClientAccountWhoamiGetResponse.php | 22 ++++++++ .../ClientDirectoryRoomAliasGetResponse.php | 23 ++++++++ .../Responses/ClientKeysUploadPostResponse.php | 21 ++++++++ .../Responses/ClientLoginGetResponse.php | 2 + .../Responses/ClientLoginPostResponse.php | 30 +++++++++++ .../Responses/ClientRefreshPostResponse.php | 22 ++++++++ .../Responses/ClientSyncGetResponse.php | 35 +++++++++++- .../Responses/ClientUserIdFilterPostResponse.php | 22 ++++++++ .../Responses/ClientVersionsGetResponse.php | 24 +++++++++ matrix-specification/Responses/LoginFlow.php | 31 ----------- .../Responses/WellKnownMatrixClientGetResponse.php | 18 +++++++ .../WellKnownMatrixSupportGetResponse.php | 33 ++++++++++++ matrix-specification/UserIdentifier.php | 45 ---------------- 57 files changed, 1302 insertions(+), 111 deletions(-) delete mode 100644 matrix-specification/AccountData.php create mode 100644 matrix-specification/Data/AccountData.php create mode 100644 matrix-specification/Data/Contact.php create mode 100644 matrix-specification/Data/DeviceKeys.php create mode 100644 matrix-specification/Data/DeviceLists.php create mode 100644 matrix-specification/Data/DiscoveryInformation.php create mode 100644 matrix-specification/Data/Filters/EventFilter.php create mode 100644 matrix-specification/Data/Filters/RoomEventFilter.php create mode 100644 matrix-specification/Data/Filters/RoomFilter.php create mode 100644 matrix-specification/Data/HomeServerInformation.php create mode 100644 matrix-specification/Data/IdentityServerInformation.php create mode 100644 matrix-specification/Data/KeyObject.php create mode 100644 matrix-specification/Data/LoginFlow.php create mode 100644 matrix-specification/Data/Presence.php create mode 100644 matrix-specification/Data/Room/Ephemeral.php create mode 100644 matrix-specification/Data/Room/InviteState.php create mode 100644 matrix-specification/Data/Room/InvitedRoom.php create mode 100644 matrix-specification/Data/Room/JoinedRoom.php create mode 100644 matrix-specification/Data/Room/KnockState.php create mode 100644 matrix-specification/Data/Room/KnockedRoom.php create mode 100644 matrix-specification/Data/Room/LeftRoom.php create mode 100644 matrix-specification/Data/Room/RoomSummary.php create mode 100644 matrix-specification/Data/Room/Rooms.php create mode 100644 matrix-specification/Data/Room/State.php create mode 100644 matrix-specification/Data/Room/ThreadNotificationCounts.php create mode 100644 matrix-specification/Data/Room/Timeline.php create mode 100644 matrix-specification/Data/Room/UnreadNotificationCounts.php create mode 100644 matrix-specification/Data/ToDevice.php create mode 100644 matrix-specification/Data/UserId.php create mode 100644 matrix-specification/Data/UserIdentifier.php create mode 100644 matrix-specification/Enums/ApiPathVersion.php create mode 100644 matrix-specification/Enums/Role.php create mode 100644 matrix-specification/Events/StrippedStateEvent.php create mode 100644 matrix-specification/Request.php create mode 100644 matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php create mode 100644 matrix-specification/Requests/ClientKeysUploadPostRequest.php delete mode 100644 matrix-specification/Requests/ClientLoginGetRequest.php create mode 100644 matrix-specification/Requests/ClientRefreshPostRequest.php create mode 100644 matrix-specification/Requests/ClientUserIdFilterPostRequest.php create mode 100644 matrix-specification/Responses/ClientAccountWhoamiGetResponse.php create mode 100644 matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php create mode 100644 matrix-specification/Responses/ClientKeysUploadPostResponse.php create mode 100644 matrix-specification/Responses/ClientLoginPostResponse.php create mode 100644 matrix-specification/Responses/ClientRefreshPostResponse.php create mode 100644 matrix-specification/Responses/ClientUserIdFilterPostResponse.php create mode 100644 matrix-specification/Responses/ClientVersionsGetResponse.php delete mode 100644 matrix-specification/Responses/LoginFlow.php create mode 100644 matrix-specification/Responses/WellKnownMatrixClientGetResponse.php create mode 100644 matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php delete mode 100644 matrix-specification/UserIdentifier.php (limited to 'matrix-specification') diff --git a/matrix-specification/AccountData.php b/matrix-specification/AccountData.php deleted file mode 100644 index b29e7fe..0000000 --- a/matrix-specification/AccountData.php +++ /dev/null @@ -1,16 +0,0 @@ - $this->events, + ]; + } +} diff --git a/matrix-specification/Data/Contact.php b/matrix-specification/Data/Contact.php new file mode 100644 index 0000000..9eeefe5 --- /dev/null +++ b/matrix-specification/Data/Contact.php @@ -0,0 +1,28 @@ + $this->emailAddress, + "matrix_id" => $this->matrixId, + "role" => $this->role, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/DeviceKeys.php b/matrix-specification/Data/DeviceKeys.php new file mode 100644 index 0000000..034263e --- /dev/null +++ b/matrix-specification/Data/DeviceKeys.php @@ -0,0 +1,31 @@ + $keys + * @param array> $signatures + */ + public function __construct( + private array $algorithms, + private string $deviceId, + private array $keys, + private array $signatures, + private string $userId, + ) + {} + + public function jsonSerialize(): array + { + return [ + "algorithms" => $this->algorithms, + "device_id" => $this->deviceId, + "keys" => $this->keys, + "signatures" => $this->signatures, + "user_id" => $this->userId, + ]; + } +} diff --git a/matrix-specification/Data/DeviceLists.php b/matrix-specification/Data/DeviceLists.php new file mode 100644 index 0000000..33d9459 --- /dev/null +++ b/matrix-specification/Data/DeviceLists.php @@ -0,0 +1,24 @@ + $this->events, + "left" => $this->events, + ]; + } +} diff --git a/matrix-specification/Data/DiscoveryInformation.php b/matrix-specification/Data/DiscoveryInformation.php new file mode 100644 index 0000000..42a3dc2 --- /dev/null +++ b/matrix-specification/Data/DiscoveryInformation.php @@ -0,0 +1,30 @@ +> $otherProperties + */ + public function __construct( + private HomeServerInformation $homeServerInformation, + private IdentityServerInformation $identityServerInformation, + private ?array $otherProperties = null, + ) + {} + + public function jsonSerialize(): array + { + return array_filter( + array_merge( + [ + "m.homeserver" => $this->homeServerInformation, + "m.identity_server" => $this->identityServerInformation, + ], + $this->otherProperties ?? [], + ), + "is_null" + ); + } +} diff --git a/matrix-specification/Data/Filters/EventFilter.php b/matrix-specification/Data/Filters/EventFilter.php new file mode 100644 index 0000000..98788ad --- /dev/null +++ b/matrix-specification/Data/Filters/EventFilter.php @@ -0,0 +1,36 @@ + $this->limit, + "not_senders" => $this->notSenders, + "not_types" => $this->notTypes, + "senders" => $this->senders, + "types" => $this->types, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Filters/RoomEventFilter.php b/matrix-specification/Data/Filters/RoomEventFilter.php new file mode 100644 index 0000000..915c9a0 --- /dev/null +++ b/matrix-specification/Data/Filters/RoomEventFilter.php @@ -0,0 +1,50 @@ +includeRedundantMembers ??= false; + $this->lazyLoadMembers ??= false; + $this->unreadThreadNotifications ??= false; + } + + public function jsonSerialize(): array + { + return parent::jsonSerialize() + array_filter([ + "contains_url" => $this->containsUrl, + "include_redundant_members" => $this->includeRedundantMembers, + "lazy_load_members" => $this->lazyLoadMembers, + "not_rooms" => $this->notRooms, + "rooms" => $this->rooms, + "unread_thread_notifications" => $this->unreadThreadNotifications, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Filters/RoomFilter.php b/matrix-specification/Data/Filters/RoomFilter.php new file mode 100644 index 0000000..dd110bd --- /dev/null +++ b/matrix-specification/Data/Filters/RoomFilter.php @@ -0,0 +1,39 @@ +includeLeave ??= false; + } + + public function jsonSerialize(): array + { + return array_filter([ + "account_data" => $this->accountData, + "ephemeral" => $this->ephemeral, + "include_leave" => $this->includeLeave, + "not_rooms" => $this->notRooms, + "rooms" => $this->rooms, + "state" => $this->state, + "timeline" => $this->timeline, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/HomeServerInformation.php b/matrix-specification/Data/HomeServerInformation.php new file mode 100644 index 0000000..15c9f10 --- /dev/null +++ b/matrix-specification/Data/HomeServerInformation.php @@ -0,0 +1,18 @@ + $this->baseUrl, + ]; + } +} diff --git a/matrix-specification/Data/IdentityServerInformation.php b/matrix-specification/Data/IdentityServerInformation.php new file mode 100644 index 0000000..bed8323 --- /dev/null +++ b/matrix-specification/Data/IdentityServerInformation.php @@ -0,0 +1,18 @@ + $this->baseUrl, + ]; + } +} diff --git a/matrix-specification/Data/KeyObject.php b/matrix-specification/Data/KeyObject.php new file mode 100644 index 0000000..120350c --- /dev/null +++ b/matrix-specification/Data/KeyObject.php @@ -0,0 +1,32 @@ + $signatures + */ + public function __construct( + private string $key, + private array $signatures, + private bool $isFallback = false, + ) + {} + + public function jsonSerialize(): array + { + $keyObject = [ + "key" => $this->key, + "signatures" => $this->signatures, + ]; + + if ($this->isFallback) { + $keyObject += [ + "fallback" => true, + ]; + } + + return $keyObject; + } +} diff --git a/matrix-specification/Data/LoginFlow.php b/matrix-specification/Data/LoginFlow.php new file mode 100644 index 0000000..6874aad --- /dev/null +++ b/matrix-specification/Data/LoginFlow.php @@ -0,0 +1,31 @@ + $this->type, + ]; + + $loginFlow += match ($this->type) { + LoginType::TOKEN => [ + "get_login_token" => $this->getLoginToken, + ], + + default => [], + }; + + return $loginFlow; + } +} diff --git a/matrix-specification/Data/Presence.php b/matrix-specification/Data/Presence.php new file mode 100644 index 0000000..971343f --- /dev/null +++ b/matrix-specification/Data/Presence.php @@ -0,0 +1,23 @@ + $this->events, + ]; + } +} diff --git a/matrix-specification/Data/Room/Ephemeral.php b/matrix-specification/Data/Room/Ephemeral.php new file mode 100644 index 0000000..bcaf22f --- /dev/null +++ b/matrix-specification/Data/Room/Ephemeral.php @@ -0,0 +1,21 @@ + $this->events, + ]; + } +} diff --git a/matrix-specification/Data/Room/InviteState.php b/matrix-specification/Data/Room/InviteState.php new file mode 100644 index 0000000..ca468ee --- /dev/null +++ b/matrix-specification/Data/Room/InviteState.php @@ -0,0 +1,23 @@ + $this->events, + ]; + } +} diff --git a/matrix-specification/Data/Room/InvitedRoom.php b/matrix-specification/Data/Room/InvitedRoom.php new file mode 100644 index 0000000..f081861 --- /dev/null +++ b/matrix-specification/Data/Room/InvitedRoom.php @@ -0,0 +1,18 @@ + $this->inviteState, + ]; + } +} diff --git a/matrix-specification/Data/Room/JoinedRoom.php b/matrix-specification/Data/Room/JoinedRoom.php new file mode 100644 index 0000000..89f64b9 --- /dev/null +++ b/matrix-specification/Data/Room/JoinedRoom.php @@ -0,0 +1,37 @@ + + */ + public function __construct( + private ?AccountData $accountData = null, + private ?Ephemeral $ephemeral = null, + private ?State $state = null, + private ?State $stateAfter = null, + private ?RoomSummary $summary = null, + private ?Timeline $timeline = null, + private ?UnreadNotificationCounts $unreadNotifications = null, + private ?array $unreadThreadNotifications = null, + ) + {} + + public function jsonSerialize(): array + { + return array_filter([ + "account_data" => $this->inviteState, + "ephemeral" => $this->ephemeral, + "state" => $this->state, + "state_after" => $this->stateAfter, + "summary" => $this->summary, + "timeline" => $this->timeline, + "unread_notifications" => $this->unreadNotifications, + "unreadThreadNotifications" => $this->unreadThreadNotifications, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Room/KnockState.php b/matrix-specification/Data/Room/KnockState.php new file mode 100644 index 0000000..e294da8 --- /dev/null +++ b/matrix-specification/Data/Room/KnockState.php @@ -0,0 +1,23 @@ + $this->events, + ]; + } +} diff --git a/matrix-specification/Data/Room/KnockedRoom.php b/matrix-specification/Data/Room/KnockedRoom.php new file mode 100644 index 0000000..cbea19f --- /dev/null +++ b/matrix-specification/Data/Room/KnockedRoom.php @@ -0,0 +1,18 @@ + $this->knockState, + ]; + } +} diff --git a/matrix-specification/Data/Room/LeftRoom.php b/matrix-specification/Data/Room/LeftRoom.php new file mode 100644 index 0000000..18e97b5 --- /dev/null +++ b/matrix-specification/Data/Room/LeftRoom.php @@ -0,0 +1,30 @@ + $this->inviteState, + "state" => $this->state, + "state_after" => $this->stateAfter, + "timeline" => $this->timeline, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Room/RoomSummary.php b/matrix-specification/Data/Room/RoomSummary.php new file mode 100644 index 0000000..91d170f --- /dev/null +++ b/matrix-specification/Data/Room/RoomSummary.php @@ -0,0 +1,25 @@ + $this->heroes, + "m.invited_member_count" => $this->invitedMemberCount, + "m.joined_member_count" => $this->joinedMemberCount, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Room/Rooms.php b/matrix-specification/Data/Room/Rooms.php new file mode 100644 index 0000000..1a84608 --- /dev/null +++ b/matrix-specification/Data/Room/Rooms.php @@ -0,0 +1,62 @@ + $invite + * @param array $join + * @param array $knock + * @param array $leave + */ + public function __construct( + private ?array $invite = null, + private ?array $join = null, + private ?array $knock = null, + private ?array $leave = null, + ) + {} + + 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(), + ]; + } + + /** + * @return InvitedRoom[] + */ + public function getInvite(): ?array + { + return $this->invite; + } + + /** + * @return JoinedRoom[] + */ + public function getJoined(): ?array + { + return $this->join; + } + + /** + * @return KnockedRoom[] + */ + public function getKnocked(): ?array + { + return $this->knock; + } + + /** + * @return LeftRoom[] + */ + public function getLeft(): ?array + { + return $this->leave; + } +} diff --git a/matrix-specification/Data/Room/State.php b/matrix-specification/Data/Room/State.php new file mode 100644 index 0000000..be9f0ef --- /dev/null +++ b/matrix-specification/Data/Room/State.php @@ -0,0 +1,23 @@ + $this->events, + ]; + } +} diff --git a/matrix-specification/Data/Room/ThreadNotificationCounts.php b/matrix-specification/Data/Room/ThreadNotificationCounts.php new file mode 100644 index 0000000..346aeb3 --- /dev/null +++ b/matrix-specification/Data/Room/ThreadNotificationCounts.php @@ -0,0 +1,20 @@ + $this->highlightCount, + "notification_count" => $this->notificationCount, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Room/Timeline.php b/matrix-specification/Data/Room/Timeline.php new file mode 100644 index 0000000..cc88472 --- /dev/null +++ b/matrix-specification/Data/Room/Timeline.php @@ -0,0 +1,27 @@ + $this->events, + "limited" => $this->limited, + "prev_batch" => $this->previousBatch, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/Room/UnreadNotificationCounts.php b/matrix-specification/Data/Room/UnreadNotificationCounts.php new file mode 100644 index 0000000..d2600e6 --- /dev/null +++ b/matrix-specification/Data/Room/UnreadNotificationCounts.php @@ -0,0 +1,20 @@ + $this->highlightCount, + "notification_count" => $this->notificationCount, + ], "is_null"); + } +} diff --git a/matrix-specification/Data/ToDevice.php b/matrix-specification/Data/ToDevice.php new file mode 100644 index 0000000..362ce06 --- /dev/null +++ b/matrix-specification/Data/ToDevice.php @@ -0,0 +1,23 @@ + $this->events, + ]; + } +} diff --git a/matrix-specification/Data/UserId.php b/matrix-specification/Data/UserId.php new file mode 100644 index 0000000..01a5e9e --- /dev/null +++ b/matrix-specification/Data/UserId.php @@ -0,0 +1,17 @@ + $this->type, + ]; + + $userIdentifier += match ($this->type) { + UserIdentifierType::USER => [ + "user" => $this->user, + ], + + UserIdentifierType::THIRDPARTY => [ + "medium" => $this->thirdPartyMedium, + "address" => $this->thirdPartyAddress, + ], + + UserIdentifierType::PHONE => [ + "country" => $this->phoneCountry, + "phone" => $this->phoneNumber, + ], + + default => [], + }; + + return $userIdentifier; + } +} diff --git a/matrix-specification/Enums/ApiPathVersion.php b/matrix-specification/Enums/ApiPathVersion.php new file mode 100644 index 0000000..5664688 --- /dev/null +++ b/matrix-specification/Enums/ApiPathVersion.php @@ -0,0 +1,11 @@ +value; diff --git a/matrix-specification/Enums/Role.php b/matrix-specification/Enums/Role.php new file mode 100644 index 0000000..f2abf9b --- /dev/null +++ b/matrix-specification/Enums/Role.php @@ -0,0 +1,14 @@ +value; + } +} diff --git a/matrix-specification/Events/PresenceEvent.php b/matrix-specification/Events/PresenceEvent.php index f71d4bd..c8c2023 100644 --- a/matrix-specification/Events/PresenceEvent.php +++ b/matrix-specification/Events/PresenceEvent.php @@ -10,22 +10,22 @@ class PresenceEvent extends SenderEvent public function __construct( string $sender, PresenceState $presence, - string $avatarUrl = "", - bool $currentlyActive = false, - string $displayName = "", - int $lastActiveAgo = 0, - string $statusMessage = "", + ?string $avatarUrl = null, + ?bool $currentlyActive = null, + ?string $displayName = null, + ?int $lastActiveAgo = null, + ?string $statusMessage = null, ) { parent::__construct( - [ + array_filter([ "avatar_url" => $avatarUrl, "currently_active" => $currentlyActive, "display_name" => $displayName, "last_active_ago" => $lastActiveAgo, "presence" => $presence, "status_msg" => $statusMessage, - ], + ], "is_null"), $sender, EventType::PRESENCE ); diff --git a/matrix-specification/Events/StrippedStateEvent.php b/matrix-specification/Events/StrippedStateEvent.php new file mode 100644 index 0000000..6e8aea6 --- /dev/null +++ b/matrix-specification/Events/StrippedStateEvent.php @@ -0,0 +1,31 @@ + $content + */ + public function __construct( + array $content, + string $sender, + private string $stateKey, + EventType $type, + ) + { + parent::__construct($content, $sender, $type); + } + + public function jsonSerialize(): array + { + return [ + "content" => $this->content, + "sender" => $this->sender, + "state_key" => $this->stateKey, + "type" => $this->type, + ]; + } +} diff --git a/matrix-specification/Request.php b/matrix-specification/Request.php new file mode 100644 index 0000000..c9f315f --- /dev/null +++ b/matrix-specification/Request.php @@ -0,0 +1,26 @@ + + */ + abstract public function getQueryParameters(): array; + + /** + * @return array + */ + abstract public function getBody(): array; + + public function jsonSerialize(): array + { + return $this->getBody(); + } +} diff --git a/matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php b/matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php new file mode 100644 index 0000000..174a5c2 --- /dev/null +++ b/matrix-specification/Requests/ClientDirectoryRoomAliasGetRequest.php @@ -0,0 +1,29 @@ +roomAlias}"; + } + + public function getQueryParameters(): array + { + return []; + } + + public function getBody(): array + { + return []; + } +} diff --git a/matrix-specification/Requests/ClientKeysUploadPostRequest.php b/matrix-specification/Requests/ClientKeysUploadPostRequest.php new file mode 100644 index 0000000..40d9eae --- /dev/null +++ b/matrix-specification/Requests/ClientKeysUploadPostRequest.php @@ -0,0 +1,29 @@ + $fallbackKeys + * @param array $oneTimeKeys + */ + public function __construct( + private ?DeviceKeys $deviceKeys = null, + private ?array $fallbackKeys = null, + private ?array $oneTimeKeys = null, + ) + {} + + public function jsonSerialize(): array + { + return array_filter([ + "device_keys" => $this->deviceKeys, + "fallback_keys" => $this->fallbackKeys, + "one_time_keys" => $this->oneTimeKeys, + ], "is_null"); + } +} diff --git a/matrix-specification/Requests/ClientLoginGetRequest.php b/matrix-specification/Requests/ClientLoginGetRequest.php deleted file mode 100644 index 73cc24c..0000000 --- a/matrix-specification/Requests/ClientLoginGetRequest.php +++ /dev/null @@ -1,6 +0,0 @@ - $this->refreshToken, + ]; + } +} diff --git a/matrix-specification/Requests/ClientSyncGetRequest.php b/matrix-specification/Requests/ClientSyncGetRequest.php index 2921fcf..2ab7d9e 100644 --- a/matrix-specification/Requests/ClientSyncGetRequest.php +++ b/matrix-specification/Requests/ClientSyncGetRequest.php @@ -2,7 +2,37 @@ namespace Matrix\Requests; -class ClientSyncGetRequest +use Matrix\Enums\PresenceState; + +class ClientSyncGetRequest implements RequiresAuthentication { - # TODO + public function __construct( + private ?string $filter = null, + private ?bool $fullState = null, + private ?PresenceState $setPresence = null, + private ?string $since = null, + private ?int $timeout = null, + private ?bool $useStateAfter = null, + ) + {} + + public function setDefaults(): void + { + $this->fullState ??= false; + $this->setPresence ??= PresenceState::ONLINE; + $this->timeout ??= 0; + $this->useStateAfter ??= false; + } + + public function getQueryParameters(): array + { + return array_filter([ + "filter" => $this->filter, + "full_state" => $this->fullState, + "set_presence" => $this->setPresence, + "since" => $this->since, + "timeout" => $this->timeout, + "use_state_after" => $this->useStateAfter, + ], "is_null"); + } } diff --git a/matrix-specification/Requests/ClientUserIdFilterPostRequest.php b/matrix-specification/Requests/ClientUserIdFilterPostRequest.php new file mode 100644 index 0000000..2edc4c5 --- /dev/null +++ b/matrix-specification/Requests/ClientUserIdFilterPostRequest.php @@ -0,0 +1,34 @@ + $this->accountData, + "event_fields" => $this->eventFields, + "event_format" => $this->eventFormat, + "presence" => $this->presence, + "room" => $this->room, + ]; + } +} diff --git a/matrix-specification/Requests/RequiresAuthentication.php b/matrix-specification/Requests/RequiresAuthentication.php index c494f13..a762405 100644 --- a/matrix-specification/Requests/RequiresAuthentication.php +++ b/matrix-specification/Requests/RequiresAuthentication.php @@ -4,5 +4,5 @@ namespace Matrix\Requests; interface RequiresAuthentication { - public function authenticateUser(): bool; + //public function authenticateUser(): bool; } diff --git a/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php b/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php new file mode 100644 index 0000000..48fbbde --- /dev/null +++ b/matrix-specification/Responses/ClientAccountWhoamiGetResponse.php @@ -0,0 +1,22 @@ + $this->deviceId, + "is_guest" => $this->isGuest, + "user_id" => $this->userId, + ], "is_null"); + } +} diff --git a/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php b/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php new file mode 100644 index 0000000..a2a6346 --- /dev/null +++ b/matrix-specification/Responses/ClientDirectoryRoomAliasGetResponse.php @@ -0,0 +1,23 @@ + $this->roomId, + "servers" => $this->servers, + ]; + } +} diff --git a/matrix-specification/Responses/ClientKeysUploadPostResponse.php b/matrix-specification/Responses/ClientKeysUploadPostResponse.php new file mode 100644 index 0000000..ff81734 --- /dev/null +++ b/matrix-specification/Responses/ClientKeysUploadPostResponse.php @@ -0,0 +1,21 @@ + $oneTimeKeyCounts + */ + public function __construct( + private array $oneTimeKeyCounts, + ) + {} + + public function jsonSerialize(): array + { + return [ + "one_time_keys_counts" => $this->oneTimeKeyCounts, + ]; + } +} diff --git a/matrix-specification/Responses/ClientLoginGetResponse.php b/matrix-specification/Responses/ClientLoginGetResponse.php index e0ccc26..b3b65c3 100644 --- a/matrix-specification/Responses/ClientLoginGetResponse.php +++ b/matrix-specification/Responses/ClientLoginGetResponse.php @@ -2,6 +2,8 @@ namespace Matrix\Responses; +use Matrix\Data\LoginFlow; + class ClientLoginGetResponse implements \JsonSerializable { /** diff --git a/matrix-specification/Responses/ClientLoginPostResponse.php b/matrix-specification/Responses/ClientLoginPostResponse.php new file mode 100644 index 0000000..4bb893d --- /dev/null +++ b/matrix-specification/Responses/ClientLoginPostResponse.php @@ -0,0 +1,30 @@ + $this->accessToken, + "device_id" => $this->deviceId, + "expires_in_ms" => $this->expiresInMilliseconds, + "refresh_token" => $this->refreshToken, + "user_id" => $this->userId, + "well_known" => $this->wellKnown, + ], "is_null"); + } +} diff --git a/matrix-specification/Responses/ClientRefreshPostResponse.php b/matrix-specification/Responses/ClientRefreshPostResponse.php new file mode 100644 index 0000000..b1e1154 --- /dev/null +++ b/matrix-specification/Responses/ClientRefreshPostResponse.php @@ -0,0 +1,22 @@ + $this->accessToken, + "expires_in_ms" => $this->expiresInMilliseconds, + "refresh_token" => $this->refreshToken, + ], "is_null"); + } +} diff --git a/matrix-specification/Responses/ClientSyncGetResponse.php b/matrix-specification/Responses/ClientSyncGetResponse.php index 27464c1..ccdc5e6 100644 --- a/matrix-specification/Responses/ClientSyncGetResponse.php +++ b/matrix-specification/Responses/ClientSyncGetResponse.php @@ -2,7 +2,38 @@ namespace Matrix\Responses; -class ClientSyncGetResponse +use Matrix\Data\AccountData; +use Matrix\Data\DeviceLists; +use Matrix\Data\Presence; +use Matrix\Data\Room\Rooms; +use Matrix\Data\ToDevice; + +class ClientSyncGetResponse implements \JsonSerializable { - # TODO + /** + * @param array $deviceOneTimeKeysCount + */ + public function __construct( + private string $nextBatch, + private ?AccountData $accountData = null, + private ?DeviceLists $deviceLists = null, + private ?array $deviceOneTimeKeysCount = null, + private ?Presence $presence = null, + private ?Rooms $rooms = null, + private ?ToDevice $toDevice = null, + ) + {} + + public function jsonSerialize(): array + { + return array_filter([ + "account_data" => $this->accountData, + "device_lists" => $this->deviceLists, + "device_one_time_keys_count" => $this->deviceOneTimeKeysCount, + "next_batch" => $this->nextBatch, + "presence" => $this->presence, + "rooms" => $this->rooms, + "to_device" => $this->toDevice, + ], "is_null"); + } } diff --git a/matrix-specification/Responses/ClientUserIdFilterPostResponse.php b/matrix-specification/Responses/ClientUserIdFilterPostResponse.php new file mode 100644 index 0000000..ed7ba37 --- /dev/null +++ b/matrix-specification/Responses/ClientUserIdFilterPostResponse.php @@ -0,0 +1,22 @@ + $this->filterId, + ]; + } +} diff --git a/matrix-specification/Responses/ClientVersionsGetResponse.php b/matrix-specification/Responses/ClientVersionsGetResponse.php new file mode 100644 index 0000000..9ec701d --- /dev/null +++ b/matrix-specification/Responses/ClientVersionsGetResponse.php @@ -0,0 +1,24 @@ + $unstableFeatures + */ + public function __construct( + private array $versions, + private ?array $unstableFeatures = null, + ) + {} + + public function jsonSerialize(): array + { + return array_filter([ + "unstable_features" => $this->unstableFeatures, + "versions" => $this->versions, + ], "is_null"); + } +} diff --git a/matrix-specification/Responses/LoginFlow.php b/matrix-specification/Responses/LoginFlow.php deleted file mode 100644 index 6ddb703..0000000 --- a/matrix-specification/Responses/LoginFlow.php +++ /dev/null @@ -1,31 +0,0 @@ - $this->type, - ]; - - $loginFlow += match ($this->type) { - LoginType::TOKEN => [ - "get_login_token" => $this->getLoginToken, - ], - - default => [], - }; - - return $loginFlow; - } -} diff --git a/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php b/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php new file mode 100644 index 0000000..769268f --- /dev/null +++ b/matrix-specification/Responses/WellKnownMatrixClientGetResponse.php @@ -0,0 +1,18 @@ +discoveryInformation; + } +} diff --git a/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php new file mode 100644 index 0000000..f38e2b0 --- /dev/null +++ b/matrix-specification/Responses/WellKnownMatrixSupportGetResponse.php @@ -0,0 +1,33 @@ + $this->contacts, + "support_page" => $this->supportPage, + ], "is_null"); + } +} diff --git a/matrix-specification/UserIdentifier.php b/matrix-specification/UserIdentifier.php deleted file mode 100644 index 63f939a..0000000 --- a/matrix-specification/UserIdentifier.php +++ /dev/null @@ -1,45 +0,0 @@ - $this->type, - ]; - - $userIdentifier += match ($this->type) { - UserIdentifierType::USER => [ - "user" => $this->user, - ], - - UserIdentifierType::THIRDPARTY => [ - "medium" => $this->thirdPartyMedium, - "address" => $this->thirdPartyAddress, - ], - - UserIdentifierType::PHONE => [ - "country" => $this->phoneCountry, - "phone" => $this->phoneNumber, - ], - - default => [], - }; - - return $userIdentifier; - } -} -- cgit v1.2.3