2021-04-02 17:20:02 +00:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-02 17:20:02 +00:00
|
|
|
/**
|
2021-05-19 16:35:13 +00:00
|
|
|
* This class defines the Object which is the primary base type for the Activity Streams vocabulary.
|
2021-04-02 17:20:02 +00:00
|
|
|
*
|
|
|
|
* 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;
|
2021-05-19 16:35:13 +00:00
|
|
|
use ActivityPub\Entities\Note;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
class NoteObject extends ObjectType
|
|
|
|
{
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $type = 'Note';
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $attributedTo;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $inReplyTo;
|
2021-05-19 16:35:13 +00:00
|
|
|
|
2021-05-18 17:16:36 +00:00
|
|
|
protected string $replies;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-05-14 17:59:35 +00:00
|
|
|
public function __construct(Note $note)
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
|
|
|
$this->id = $note->uri;
|
|
|
|
|
|
|
|
$this->content = $note->message_html;
|
|
|
|
$this->published = $note->published_at->format(DATE_W3C);
|
|
|
|
$this->attributedTo = $note->actor->uri;
|
|
|
|
|
2021-06-09 12:40:22 +00:00
|
|
|
if ($note->in_reply_to_id !== null) {
|
2021-04-02 17:20:02 +00:00
|
|
|
$this->inReplyTo = $note->reply_to_note->uri;
|
|
|
|
}
|
|
|
|
|
2021-06-08 09:52:11 +00:00
|
|
|
$this->replies = base_url(route_to('note-replies', $note->actor->username, $note->id));
|
2021-04-02 17:20:02 +00:00
|
|
|
|
|
|
|
$this->cc = [$note->actor->followers_url];
|
|
|
|
}
|
|
|
|
}
|