summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/PresenceEvent.php
blob: da40af4884b1597355c641320bb013271669091f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?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 = 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,
      ], fn ($value) => ! is_null($value)),
      $sender,
      EventType::PRESENCE
    );
  }
}