summaryrefslogtreecommitdiff
path: root/matrix-specification/Data/Room
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Data/Room')
-rw-r--r--matrix-specification/Data/Room/AllowCondition.php24
-rw-r--r--matrix-specification/Data/Room/AvatarInfo.php28
-rw-r--r--matrix-specification/Data/Room/JoinedRoom.php4
-rw-r--r--matrix-specification/Data/Room/PreviousRoom.php20
-rw-r--r--matrix-specification/Data/Room/Rooms.php10
-rw-r--r--matrix-specification/Data/Room/TextualRepresentation.php20
-rw-r--r--matrix-specification/Data/Room/ThumbnailInfo.php24
-rw-r--r--matrix-specification/Data/Room/TopicContentBlock.php21
8 files changed, 144 insertions, 7 deletions
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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class AllowCondition implements \JsonSerializable
+{
+ public function __construct(
+ private string $type,
+ private ?string $roomId = null,
+ )
+ {
+ if ($type == "m.room.membership" && empty($roomId)) {
+ throw new \InvalidArgumentException("room id is required");
+ }
+ }
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "room_id" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class AvatarInfo implements \JsonSerializable
+{
+ public function __construct(
+ private int $height,
+ private string $mimeType,
+ private int $fileSize,
+ private ThumbnailInfo $thumbnailInfo,
+ private string $thumbnailUrl,
+ private int $width,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "h" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class PreviousRoom implements \JsonSerializable
+{
+ public function __construct(
+ private string $roomId,
+ private ?string $eventId = null,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "event_id" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class TextualRepresentation implements \JsonSerializable
+{
+ public function __construct(
+ private string $body,
+ private ?string $mimeType = "text/plain",
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return array_filter([
+ "body" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class ThumbnailInfo implements \JsonSerializable
+{
+ public function __construct(
+ private int $height,
+ private string $mimeType,
+ private int $fileSize,
+ private int $width,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "h" => $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 @@
+<?php
+
+namespace Matrix\Data\Room;
+
+class TopicContentBlock implements \JsonSerializable
+{
+ /**
+ * @param TextualRepresentation[] $text
+ */
+ public function __construct(
+ private array $text,
+ )
+ {}
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "m.text" => $this->text,
+ ];
+ }
+}