summaryrefslogtreecommitdiff
path: root/matrix-specification
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2026-03-05 14:57:28 +0100
committerDaniel Weipert <git@mail.dweipert.de>2026-03-05 14:57:28 +0100
commitbd11271621bd3759cfd194ed0119c0dc28155fd0 (patch)
tree319b4790d4e2b05513abf023732ed6fb0717f603 /matrix-specification
parent2386148b8f048ba40d9f26cc97898bdcdc778ea2 (diff)
updateHEADmain
Diffstat (limited to 'matrix-specification')
-rw-r--r--matrix-specification/Data/DeviceLists.php4
-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
-rw-r--r--matrix-specification/Data/UnsignedData.php (renamed from matrix-specification/Events/UnsignedData.php)3
-rw-r--r--matrix-specification/Enums/EventType.php8
-rw-r--r--matrix-specification/Enums/MessageFormat.php13
-rw-r--r--matrix-specification/Enums/MessageType.php20
-rw-r--r--matrix-specification/Enums/RoomGuestAccess.php14
-rw-r--r--matrix-specification/Enums/RoomHistoryVisibility.php16
-rw-r--r--matrix-specification/Enums/RoomJoinRule.php18
-rw-r--r--matrix-specification/Enums/RoomVisibility.php14
-rw-r--r--matrix-specification/Events/ClientEvent.php41
-rw-r--r--matrix-specification/Events/ClientEventWithoutRoomId.php32
-rw-r--r--matrix-specification/Events/Event.php13
-rw-r--r--matrix-specification/Events/Message/FormattedMessageEvent.php39
-rw-r--r--matrix-specification/Events/Message/MessageEvent.php35
-rw-r--r--matrix-specification/Events/Message/TextMessageEvent.php38
-rw-r--r--matrix-specification/Events/PresenceEvent.php9
-rw-r--r--matrix-specification/Events/Room/AvatarEvent.php37
-rw-r--r--matrix-specification/Events/Room/CanonicalAliasEvent.php39
-rw-r--r--matrix-specification/Events/Room/CreateEvent.php54
-rw-r--r--matrix-specification/Events/Room/GuestAccessEvent.php35
-rw-r--r--matrix-specification/Events/Room/HistoryVisibilityEvent.php35
-rw-r--r--matrix-specification/Events/Room/JoinRulesEvent.php40
-rw-r--r--matrix-specification/Events/Room/MemberEvent.php47
-rw-r--r--matrix-specification/Events/Room/NameEvent.php34
-rw-r--r--matrix-specification/Events/Room/PinnedEventsEvent.php37
-rw-r--r--matrix-specification/Events/Room/PowerLevelsEvent.php57
-rw-r--r--matrix-specification/Events/Room/TopicEvent.php37
-rw-r--r--matrix-specification/Events/SenderEvent.php14
-rw-r--r--matrix-specification/Events/StateEvent.php50
-rw-r--r--matrix-specification/Events/StrippedStateEvent.php4
-rw-r--r--matrix-specification/Responses/ClientKeysUploadPostResponse.php2
39 files changed, 944 insertions, 46 deletions
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 @@
+<?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,
+ ];
+ }
+}
diff --git a/matrix-specification/Events/UnsignedData.php b/matrix-specification/Data/UnsignedData.php
index 3c5cd46..a1748cf 100644
--- a/matrix-specification/Events/UnsignedData.php
+++ b/matrix-specification/Data/UnsignedData.php
@@ -1,8 +1,9 @@
<?php
-namespace Matrix\Events;
+namespace Matrix\Data;
use Matrix\Enums\MembershipState;
+use Matrix\Events\ClientEvent;
/**
* @see https://spec.matrix.org/v1.16/client-server-api/#definition-clientevent_unsigneddata
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 @@
+<?php
+
+namespace Matrix\Enums;
+
+enum MessageFormat: string
+{
+ case HTML = "org.matrix.custom.html";
+
+ public function jsonSerialize(): string
+ {
+ return $this->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 @@
+<?php
+
+namespace Matrix\Enums;
+
+enum MessageType: string
+{
+ case AUDIO = "m.audio";
+ case EMOTE = "m.emote";
+ case FILE = "m.file";
+ case IMAGE = "m.image";
+ case KEY_VERIFICATION_REQUEST = "m.key.verification.request";
+ case NOTICE = "m.notice";
+ case TEXT = "m.text";
+ case VIDEO = "m.video";
+
+ public function jsonSerialize(): string
+ {
+ return $this->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 @@
+<?php
+
+namespace Matrix\Enums;
+
+enum RoomGuestAccess: string
+{
+ case CAN_JOIN = "can_join";
+ case FORBIDDEN = "forbidden";
+
+ public function jsonSerialize(): string
+ {
+ return $this->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 @@
+<?php
+
+namespace Matrix\Enums;
+
+enum RoomHistoryVisibility: string
+{
+ case INVITED = "invited";
+ case JOINED = "joined";
+ case SHARED = "shared";
+ case WORLD_READABLE = "world_readable";
+
+ public function jsonSerialize(): string
+ {
+ return $this->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 @@
+<?php
+
+namespace Matrix\Enums;
+
+enum RoomJoinRule: string implements \JsonSerializable
+{
+ case INVITE = "invite";
+ case KNOCK = "knock";
+ case KNOCK_RESTRICTED = "knock_restricted";
+ case PRIVATE = "private";
+ case PUBLIC = "public";
+ case RESTRICTED = "restricted";
+
+ public function jsonSerialize(): string
+ {
+ return $this->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 @@
+<?php
+
+namespace Matrix\Enums;
+
+enum RoomVisibility: string implements \JsonSerializable
+{
+ case PRIVATE = "private";
+ case PUBLIC = "public";
+
+ public function jsonSerialize(): string
+ {
+ return $this->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<string, mixed>
+ */
+ 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 @@
+<?php
+
+namespace Matrix\Events\Message;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MessageFormat;
+use Matrix\Enums\MessageType;
+
+class FormattedMessageEvent extends MessageEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $body,
+ MessageType $msgtype,
+ ?MessageFormat $format = null,
+ ?string $formattedBody = null,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "body" => $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 @@
+<?php
+
+namespace Matrix\Events\Message;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MessageType;
+use Matrix\Events\ClientEvent;
+
+class MessageEvent extends ClientEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $body,
+ MessageType $msgtype,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "body" => $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 @@
+<?php
+
+namespace Matrix\Events\Message;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MessageFormat;
+use Matrix\Enums\MessageType;
+
+class TextMessageEvent extends FormattedMessageEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $body,
+ ?MessageFormat $format = null,
+ ?string $formattedBody = null,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "body" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\Room\AvatarInfo;
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class AvatarEvent extends StateEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ ?AvatarInfo $info = null,
+ ?string $url = null,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "info" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class CanonicalAliasEvent extends StateEvent
+{
+ /**
+ * @param ?string[] $altAliases
+ */
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ ?string $alias = null,
+ ?array $altAliases = null,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "alias" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\Room\PreviousRoom;
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class CreateEvent extends StateEvent
+{
+ /**
+ * @param ?string[] $additionalCreators
+ */
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $roomVersion,
+ ?array $additionalCreators = null,
+ ?string $creator = null,
+ bool $federate = true,
+ ?PreviousRoom $predecessor = null,
+ ?string $roomType = null,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ if (intval($roomVersion) <= 10) {
+ if (empty($creator)) {
+ throw new \InvalidArgumentException("creator is required in room versions 1 - 10");
+ }
+ }
+
+ parent::__construct(
+ array_filter([
+ "additional_creators" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\RoomGuestAccess;
+use Matrix\Events\StateEvent;
+
+class GuestAccessEvent extends StateEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ RoomGuestAccess $guestAccess,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ [
+ "guest_access" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\RoomHistoryVisibility;
+use Matrix\Events\StateEvent;
+
+class HistoryVisibilityEvent extends StateEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ RoomHistoryVisibility $historyVisibility,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ [
+ "history_visibility" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\RoomJoinRule;
+use Matrix\Events\StateEvent;
+
+class JoinRulesEvent extends StateEvent
+{
+ /**
+ * @param ?AllowCondition[] $allow
+ */
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ RoomJoinRule $joinRule,
+ ?array $allow = null,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "allow" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Enums\MembershipState;
+use Matrix\Events\StateEvent;
+
+class MemberEvent extends StateEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $stateKey,
+ bool $isDirect,
+ MembershipState $membership,
+ ?string $avatarUrl = null,
+ ?string $displayName = null,
+ ?string $joinAuthorisedViaUsersServer = null,
+ ?string $reason = null,
+ ?object $thirdPartyInvite = null, # TODO: https://spec.matrix.org/v1.17/client-server-api/#mroommember_thirdpartyinvite
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "avatar_url" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class NameEvent extends StateEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $name,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ [
+ "name" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class PinnedEventsEvent extends StateEvent
+{
+ /**
+ * @param string[] $pinned
+ */
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ array $pinned,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ [
+ "pinned" => $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class PowerLevelsEvent extends StateEvent
+{
+ /**
+ * @param ?array<string, int> $events This is a mapping from event type to power level required.
+ * @param ?array<string, int> $notifications This is a mapping from key to power level for that notifications key.
+ * @param ?array<string, int> $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 @@
+<?php
+
+namespace Matrix\Events\Room;
+
+use Matrix\Data\Room\TopicContentBlock;
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+use Matrix\Events\StateEvent;
+
+class TopicEvent extends StateEvent
+{
+ public function __construct(
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ string $topic,
+ ?TopicContentBlock $topicContentBlock = null,
+ string $stateKey = "",
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ array_filter([
+ "m.topic" => $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 @@
+<?php
+
+namespace Matrix\Events;
+
+use Matrix\Data\UnsignedData;
+use Matrix\Enums\EventType;
+
+class StateEvent extends ClientEvent
+{
+ public function __construct(
+ array $content,
+ string $eventId,
+ int $originServerTimestamp,
+ string $roomId,
+ string $sender,
+ protected string $stateKey,
+ EventType $type,
+ ?UnsignedData $unsigned = null,
+ )
+ {
+ parent::__construct(
+ $content,
+ $eventId,
+ $originServerTimestamp,
+ $roomId,
+ $sender,
+ $type,
+ $unsigned,
+ );
+ }
+
+ public function jsonSerialize(): array
+ {
+ return [
+ "content" => $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/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,
];
}
}