summaryrefslogtreecommitdiff
path: root/matrix-specification/Events
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Events')
-rw-r--r--matrix-specification/Events/PresenceEvent.php14
-rw-r--r--matrix-specification/Events/StrippedStateEvent.php31
2 files changed, 38 insertions, 7 deletions
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 @@
+<?php
+
+namespace Matrix\Events;
+
+use Matrix\Enums\EventType;
+
+class StrippedStateEvent extends SenderEvent
+{
+ /**
+ * @param array<string, mixed> $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,
+ ];
+ }
+}