summaryrefslogtreecommitdiff
path: root/matrix-specification/Events/PresenceEvent.php
blob: f71d4bdfdc77e9a818589ce93f07e07b1c7ddac8 (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
34
35
36
37
38
39
40
41
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,
    ];
  }
}