2021-04-02 19:20:02 +02:00
|
|
|
<?php
|
|
|
|
|
2021-06-08 11:52:11 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2021-04-02 19:20:02 +02:00
|
|
|
/**
|
2021-05-19 18:35:13 +02:00
|
|
|
* This class defines the Object which is the primary base type for the Activity Streams vocabulary.
|
2021-04-02 19:20:02 +02:00
|
|
|
*
|
|
|
|
* Object is a reserved word in php, so the class is named ObjectType.
|
|
|
|
*
|
2022-02-19 17:06:11 +01:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-04-02 19:20:02 +02:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 13:05:16 +02:00
|
|
|
namespace Modules\Fediverse\Objects;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2021-08-23 13:05:16 +02:00
|
|
|
use Modules\Fediverse\Core\ObjectType;
|
|
|
|
use Modules\Fediverse\Entities\Post;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
|
|
|
class NoteObject extends ObjectType
|
|
|
|
{
|
2021-05-18 19:16:36 +02:00
|
|
|
protected string $type = 'Note';
|
2021-05-19 18:35:13 +02:00
|
|
|
|
2021-05-18 19:16:36 +02:00
|
|
|
protected string $attributedTo;
|
2021-05-19 18:35:13 +02:00
|
|
|
|
2021-05-18 19:16:36 +02:00
|
|
|
protected string $inReplyTo;
|
2021-05-19 18:35:13 +02:00
|
|
|
|
2021-05-18 19:16:36 +02:00
|
|
|
protected string $replies;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2021-08-23 13:05:16 +02:00
|
|
|
/**
|
|
|
|
* @param Post $post
|
|
|
|
*/
|
|
|
|
public function __construct($post)
|
2021-04-02 19:20:02 +02:00
|
|
|
{
|
2021-08-13 13:07:29 +02:00
|
|
|
$this->id = $post->uri;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2021-08-13 13:07:29 +02:00
|
|
|
$this->content = $post->message_html;
|
|
|
|
$this->published = $post->published_at->format(DATE_W3C);
|
|
|
|
$this->attributedTo = $post->actor->uri;
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2021-08-13 13:07:29 +02:00
|
|
|
if ($post->in_reply_to_id !== null) {
|
2022-02-03 13:11:01 +01:00
|
|
|
$this->to[] = $post->reply_to_post->actor->uri;
|
|
|
|
|
2021-08-13 13:07:29 +02:00
|
|
|
$this->inReplyTo = $post->reply_to_post->uri;
|
2021-04-02 19:20:02 +02:00
|
|
|
}
|
|
|
|
|
2022-03-04 15:33:48 +01:00
|
|
|
$this->replies = url_to('post-replies', esc($post->actor->username), $post->id);
|
2021-04-02 19:20:02 +02:00
|
|
|
|
2021-08-13 13:07:29 +02:00
|
|
|
$this->cc = [$post->actor->followers_url];
|
2021-04-02 19:20:02 +02:00
|
|
|
}
|
|
|
|
}
|