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 --- .../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 ++++++++++++++++++++ 12 files changed, 250 insertions(+), 33 deletions(-) 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 (limited to 'matrix-specification/Responses') 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"); + } +} -- cgit v1.2.3