NoteObject.php 1.13 KB
Newer Older
1
2
<?php

3
4
declare(strict_types=1);

5
/**
6
 * This class defines the Object which is the primary base type for the Activity Streams vocabulary.
7
8
9
10
11
12
13
14
15
16
17
 *
 * Object is a reserved word in php, so the class is named ObjectType.
 *
 * @copyright  2021 Podlibre
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
 * @link       https://castopod.org/
 */

namespace ActivityPub\Objects;

use ActivityPub\Core\ObjectType;
18
use ActivityPub\Entities\Status;
19
20
21

class NoteObject extends ObjectType
{
22
    protected string $type = 'Note';
23

24
    protected string $attributedTo;
25

26
    protected string $inReplyTo;
27

28
    protected string $replies;
29

30
    public function __construct(Status $status)
31
    {
32
        $this->id = $status->uri;
33

34
35
36
        $this->content = $status->message_html;
        $this->published = $status->published_at->format(DATE_W3C);
        $this->attributedTo = $status->actor->uri;
37

38
39
        if ($status->in_reply_to_id !== null) {
            $this->inReplyTo = $status->reply_to_status->uri;
40
41
        }

42
        $this->replies = url_to('status-replies', $status->actor->username, $status->id);
43

44
        $this->cc = [$status->actor->followers_url];
45
46
    }
}