summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/PresenceEvent.php
diff options
context:
space:
mode:
Diffstat (limited to 'matrix-specification/Events/PresenceEvent.php')
-rw-r--r--matrix-specification/Events/PresenceEvent.php42
1 files changed, 42 insertions, 0 deletions
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 @@
+<?php
+
+namespace Matrix\Events;
+
+use Matrix\Enums\EventType;
+use Matrix\Enums\PresenceState;
+
+class PresenceEvent extends SenderEvent
+{
+ public function __construct(
+ string $sender,
+ PresenceState $presence,
+ string $avatarUrl = "",
+ bool $currentlyActive = false,
+ string $displayName = "",
+ int $lastActiveAgo = 0,
+ string $statusMessage = "",
+ )
+ {
+ parent::__construct(
+ [
+ "avatar_url" => $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,
+ ];
+ }
+}