summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-09-25 13:38:24 +0200
committerDaniel Weipert <git@mail.dweipert.de>2025-09-25 13:38:24 +0200
commitb19a8f63ad727a3633885d3f2b81edf8181a53b9 (patch)
tree6b5fd70224a125a16010a291e5fd0df834e9436f /matrix-specification/Data/Room
parentb08047ba485f86038f33175162943c0a9878ab1a (diff)
matrix-specification split work in progress
Diffstat (limited to 'matrix-specification/Data/Room')
-rw-r--r--matrix-specification/Data/Room/Ephemeral.php21
-rw-r--r--matrix-specification/Data/Room/InviteState.php23
-rw-r--r--matrix-specification/Data/Room/InvitedRoom.php18
-rw-r--r--matrix-specification/Data/Room/JoinedRoom.php37
-rw-r--r--matrix-specification/Data/Room/KnockState.php23
-rw-r--r--matrix-specification/Data/Room/KnockedRoom.php18
-rw-r--r--matrix-specification/Data/Room/LeftRoom.php30
-rw-r--r--matrix-specification/Data/Room/RoomSummary.php25
-rw-r--r--matrix-specification/Data/Room/Rooms.php62
-rw-r--r--matrix-specification/Data/Room/State.php23
-rw-r--r--matrix-specification/Data/Room/ThreadNotificationCounts.php20
-rw-r--r--matrix-specification/Data/Room/Timeline.php27
-rw-r--r--matrix-specification/Data/Room/UnreadNotificationCounts.php20
13 files changed, 347 insertions, 0 deletions
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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class Ephemeral implements \JsonSerializable
+{
+ /**
+ * @param Event[] $events
+ */
+ public function __construct(
+ private array $events,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "events" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+use Matrix\Events\StrippedStateEvent;
+
+class InviteState implements \JsonSerializable
+{
+ /**
+ * @param StrippedStateEvent[] $events
+ */
+ public function __construct(
+ private array $events,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "events" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class InvitedRoom implements \JsonSerializable
+{
+ public function __construct(
+ private InviteState $inviteState,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "invite_state" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+use Matrix\Data\AccountData;
+
+class JoinedRoom implements \JsonSerializable
+{
+ /**
+ * @param array<string, ThreadNotificationCounts>
+ */
+ 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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+use Matrix\Events\StrippedStateEvent;
+
+class KnockState implements \JsonSerializable
+{
+ /**
+ * @param StrippedStateEvent[] $events
+ */
+ public function __construct(
+ private array $events,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "events" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class KnockedRoom implements \JsonSerializable
+{
+ public function __construct(
+ private KnockState $knockState,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "knock_state" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+use Matrix\Data\AccountData;
+
+/**
+ * @see https://spec.matrix.org/v1.16/client-server-api/#get_matrixclientv3sync_response-200_left-room
+ * TODO: validate against request. add ValidatesAgainstRequest interface? and MatrixRequest base class?
+ */
+class LeftRoom implements \JsonSerializable
+{
+ public function __construct(
+ private ?AccountData $accountData = null,
+ private ?State $state = null,
+ private ?State $stateAfter = null,
+ private ?Timeline $timeline = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "account_data" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class RoomSummary implements \JsonSerializable
+{
+ /**
+ * @param string[] $heroes
+ */
+ public function __construct(
+ private ?array $heroes = null,
+ private ?int $invitedMemberCount = null,
+ private ?int $joinedMemberCount = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "m.heroes" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class Rooms implements \JsonSerializable
+{
+ /**
+ * @param array<string, InvitedRoom> $invite
+ * @param array<string, JoinedRoom> $join
+ * @param array<string, KnockedRoom> $knock
+ * @param array<string, LeftRoom> $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+use Matrix\Events\ClientEventWithoutRoomId;
+
+class State implements \JsonSerializable
+{
+ /**
+ * @param ClientEventWithoutRoomId[] $events
+ */
+ public function __construct(
+ private array $events,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "events" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class ThreadNotificationCounts implements \JsonSerializable
+{
+ public function __construct(
+ private ?int $highlightCount = null,
+ private ?int $notificationCount = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "highlight_count" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+use Matrix\Events\ClientEventWithoutRoomId;
+
+class Timeline implements \JsonSerializable
+{
+ /**
+ * @param ClientEventWithoutRoomId[] $events
+ */
+ public function __construct(
+ private array $events,
+ private ?bool $limited = null,
+ private ?string $previousBatch = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "events" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class UnreadNotificationCounts implements \JsonSerializable
+{
+ public function __construct(
+ private ?int $highlightCount = null,
+ private ?int $notificationCount = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "highlight_count" => $this->highlightCount,
+ "notification_count" => $this->notificationCount,
+ ], "is_null");
+ }
+}