3 * @copyright Copyright (C) 2010-2023, the Friendica project
5 * @license GNU AGPL version 3 or any later version
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 namespace Friendica\Object\Api\Mastodon;
24 use Friendica\BaseDataTransferObject;
25 use Friendica\Content\Text\BBCode;
26 use Friendica\Util\DateTimeFormat;
29 * Class ScheduledStatus
31 * @see https://docs.joinmastodon.org/entities/scheduledstatus
33 class ScheduledStatus extends BaseDataTransferObject
37 /** @var string (Datetime) */
38 protected $scheduled_at;
44 'spoiler_text' => null,
46 'scheduled_at' => null,
48 'idempotency' => null,
49 'in_reply_to_id' => null,
50 'application_id' => ''
52 /** @var Attachment */
53 protected $media_attachments = [];
56 * Creates a status record from a delayed-post record.
58 * @param array $delayed_post Record with the delayed post
59 * @param array $parameters Parameters for the workerqueue entry for the delayed post
60 * @throws \Friendica\Network\HTTPException\InternalServerErrorException
62 public function __construct(array $delayed_post, array $parameters, array $media_ids = null, array $media_attachments = [], int $in_reply_to_id = null)
64 $visibility = ['public', 'private', 'unlisted'];
66 $this->id = (string)$delayed_post['id'];
67 $this->scheduled_at = DateTimeFormat::utc($delayed_post['delayed'], DateTimeFormat::JSON);
70 'text' => BBCode::convert(BBCode::setMentionsToNicknames($parameters['item']['body'] ?? ''), false, BBCode::MASTODON_API),
71 'media_ids' => $media_ids,
73 'spoiler_text' => $parameters['item']['title'] ?? '',
74 'visibility' => $visibility[$parameters['item']['private'] ?? 1],
75 'scheduled_at' => $this->scheduled_at,
77 'idempotency' => null,
78 'in_reply_to_id' => $in_reply_to_id,
79 'application_id' => ''
82 $this->media_attachments = $media_attachments;