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 --- matrix-specification/Events/PresenceEvent.php | 14 +++++----- matrix-specification/Events/StrippedStateEvent.php | 31 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 matrix-specification/Events/StrippedStateEvent.php (limited to 'matrix-specification/Events') diff --git a/matrix-specification/Events/PresenceEvent.php b/matrix-specification/Events/PresenceEvent.php index f71d4bd..c8c2023 100644 --- a/matrix-specification/Events/PresenceEvent.php +++ b/matrix-specification/Events/PresenceEvent.php @@ -10,22 +10,22 @@ class PresenceEvent extends SenderEvent public function __construct( string $sender, PresenceState $presence, - string $avatarUrl = "", - bool $currentlyActive = false, - string $displayName = "", - int $lastActiveAgo = 0, - string $statusMessage = "", + ?string $avatarUrl = null, + ?bool $currentlyActive = null, + ?string $displayName = null, + ?int $lastActiveAgo = null, + ?string $statusMessage = null, ) { parent::__construct( - [ + array_filter([ "avatar_url" => $avatarUrl, "currently_active" => $currentlyActive, "display_name" => $displayName, "last_active_ago" => $lastActiveAgo, "presence" => $presence, "status_msg" => $statusMessage, - ], + ], "is_null"), $sender, EventType::PRESENCE ); diff --git a/matrix-specification/Events/StrippedStateEvent.php b/matrix-specification/Events/StrippedStateEvent.php new file mode 100644 index 0000000..6e8aea6 --- /dev/null +++ b/matrix-specification/Events/StrippedStateEvent.php @@ -0,0 +1,31 @@ + $content + */ + public function __construct( + array $content, + string $sender, + private string $stateKey, + EventType $type, + ) + { + parent::__construct($content, $sender, $type); + } + + public function jsonSerialize(): array + { + return [ + "content" => $this->content, + "sender" => $this->sender, + "state_key" => $this->stateKey, + "type" => $this->type, + ]; + } +} -- cgit v1.2.3