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.
|
|
|
|
*
|
2022-02-19 16:06:11 +00:00
|
|
|
* @copyright 2021 Ad Aures
|
2021-04-02 17:20:02 +00:00
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
namespace Modules\Fediverse\Objects;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-08-23 11:05:16 +00:00
|
|
|
use Modules\Fediverse\Core\ObjectType;
|
|
|
|
use Modules\Fediverse\Entities\Post;
|
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-08-23 11:05:16 +00:00
|
|
|
/**
|
|
|
|
* @param Post $post
|
|
|
|
*/
|
|
|
|
public function __construct($post)
|
2021-04-02 17:20:02 +00:00
|
|
|
{
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->id = $post->uri;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->content = $post->message_html;
|
|
|
|
$this->published = $post->published_at->format(DATE_W3C);
|
|
|
|
$this->attributedTo = $post->actor->uri;
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-08-13 11:07:29 +00:00
|
|
|
if ($post->in_reply_to_id !== null) {
|
2022-02-03 12:11:01 +00:00
|
|
|
$this->to[] = $post->reply_to_post->actor->uri;
|
|
|
|
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->inReplyTo = $post->reply_to_post->uri;
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
|
2022-03-04 14:33:48 +00:00
|
|
|
$this->replies = url_to('post-replies', esc($post->actor->username), $post->id);
|
2021-04-02 17:20:02 +00:00
|
|
|
|
2021-08-13 11:07:29 +00:00
|
|
|
$this->cc = [$post->actor->followers_url];
|
2021-04-02 17:20:02 +00:00
|
|
|
}
|
|
|
|
}
|