From b08047ba485f86038f33175162943c0a9878ab1a Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 19 Sep 2025 17:03:47 +0200 Subject: add separate matrix specification package --- matrix-specification/Events/ClientEvent.php | 32 +++++++++++++++++ .../Events/ClientEventWithoutRoomId.php | 34 ++++++++++++++++++ matrix-specification/Events/Event.php | 17 +++++++++ matrix-specification/Events/PresenceEvent.php | 42 ++++++++++++++++++++++ matrix-specification/Events/SenderEvent.php | 20 +++++++++++ matrix-specification/Events/UnsignedData.php | 31 ++++++++++++++++ 6 files changed, 176 insertions(+) create mode 100644 matrix-specification/Events/ClientEvent.php create mode 100644 matrix-specification/Events/ClientEventWithoutRoomId.php create mode 100644 matrix-specification/Events/Event.php create mode 100644 matrix-specification/Events/PresenceEvent.php create mode 100644 matrix-specification/Events/SenderEvent.php create mode 100644 matrix-specification/Events/UnsignedData.php (limited to 'matrix-specification/Events') diff --git a/matrix-specification/Events/ClientEvent.php b/matrix-specification/Events/ClientEvent.php new file mode 100644 index 0000000..be1e354 --- /dev/null +++ b/matrix-specification/Events/ClientEvent.php @@ -0,0 +1,32 @@ + $this->roomId, + ]; + + return $clientEvent; + } +} diff --git a/matrix-specification/Events/ClientEventWithoutRoomId.php b/matrix-specification/Events/ClientEventWithoutRoomId.php new file mode 100644 index 0000000..0410d5b --- /dev/null +++ b/matrix-specification/Events/ClientEventWithoutRoomId.php @@ -0,0 +1,34 @@ + $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, + ]; + } +} diff --git a/matrix-specification/Events/Event.php b/matrix-specification/Events/Event.php new file mode 100644 index 0000000..fe85f48 --- /dev/null +++ b/matrix-specification/Events/Event.php @@ -0,0 +1,17 @@ + $content + */ + public function __construct( + protected array $content, + protected EventType $type, + ) + {} +} diff --git a/matrix-specification/Events/PresenceEvent.php b/matrix-specification/Events/PresenceEvent.php new file mode 100644 index 0000000..f71d4bd --- /dev/null +++ b/matrix-specification/Events/PresenceEvent.php @@ -0,0 +1,42 @@ + $avatarUrl, + "currently_active" => $currentlyActive, + "display_name" => $displayName, + "last_active_ago" => $lastActiveAgo, + "presence" => $presence, + "status_msg" => $statusMessage, + ], + $sender, + EventType::PRESENCE + ); + } + + public function jsonSerialize(): array + { + return [ + "content" => $this->content, + "sender" => $this->sender, + "type" => $this->type, + ]; + } +} diff --git a/matrix-specification/Events/SenderEvent.php b/matrix-specification/Events/SenderEvent.php new file mode 100644 index 0000000..f3d4ceb --- /dev/null +++ b/matrix-specification/Events/SenderEvent.php @@ -0,0 +1,20 @@ + $content + */ + public function __construct( + array $content, + protected string $sender, + EventType $type, + ) + { + parent::__construct($content, $type); + } +} diff --git a/matrix-specification/Events/UnsignedData.php b/matrix-specification/Events/UnsignedData.php new file mode 100644 index 0000000..924af29 --- /dev/null +++ b/matrix-specification/Events/UnsignedData.php @@ -0,0 +1,31 @@ + $this->age, + "membership" => $this->membership, + "prev_content" => $this->previousContent, + "redacted_because" => $this->redactedBecause, + "transaction_id" => $this->transactionId, + ], "is_null"); + } +} -- cgit v1.2.3