2021-07-29 10:34:31 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2022-01-02 08:27:47 +01:00
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
2021-07-29 10:34:31 +00:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Friendica\Object\Api\Mastodon;
|
|
|
|
|
|
|
|
use Friendica\BaseDataTransferObject;
|
|
|
|
use Friendica\Content\Text\BBCode;
|
|
|
|
use Friendica\Util\DateTimeFormat;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ScheduledStatus
|
|
|
|
*
|
|
|
|
* @see https://docs.joinmastodon.org/entities/scheduledstatus
|
|
|
|
*/
|
|
|
|
class ScheduledStatus extends BaseDataTransferObject
|
|
|
|
{
|
|
|
|
/** @var string */
|
|
|
|
protected $id;
|
|
|
|
/** @var string (Datetime) */
|
|
|
|
protected $scheduled_at;
|
|
|
|
/** @var array */
|
|
|
|
protected $params = [
|
|
|
|
'text' => '',
|
|
|
|
'media_ids' => null,
|
|
|
|
'sensitive' => null,
|
|
|
|
'spoiler_text' => null,
|
|
|
|
'visibility' => '',
|
|
|
|
'scheduled_at' => null,
|
|
|
|
'poll' => null,
|
|
|
|
'idempotency' => null,
|
|
|
|
'in_reply_to_id' => null,
|
|
|
|
'application_id' => ''
|
|
|
|
];
|
|
|
|
/** @var Attachment */
|
|
|
|
protected $media_attachments = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a status record from a delayed-post record.
|
|
|
|
*
|
2021-07-30 10:24:08 +00:00
|
|
|
* @param array $delayed_post Record with the delayed post
|
|
|
|
* @param array $parameters Parameters for the workerqueue entry for the delayed post
|
2021-07-29 10:34:31 +00:00
|
|
|
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
|
|
|
*/
|
2021-07-30 22:39:13 +00:00
|
|
|
public function __construct(array $delayed_post, array $parameters, array $media_ids = null, array $media_attachments = [], int $in_reply_to_id = null)
|
2021-07-29 10:34:31 +00:00
|
|
|
{
|
|
|
|
$visibility = ['public', 'private', 'unlisted'];
|
|
|
|
|
2021-07-29 14:58:04 +00:00
|
|
|
$this->id = (string)$delayed_post['id'];
|
2021-07-29 15:01:09 +00:00
|
|
|
$this->scheduled_at = DateTimeFormat::utc($delayed_post['delayed'], DateTimeFormat::JSON);
|
2021-07-29 10:34:31 +00:00
|
|
|
|
|
|
|
$this->params = [
|
|
|
|
'text' => BBCode::convert(BBCode::setMentionsToNicknames($parameters['item']['body'] ?? ''), false, BBCode::API),
|
2021-07-30 13:22:06 +00:00
|
|
|
'media_ids' => $media_ids,
|
2021-07-29 10:34:31 +00:00
|
|
|
'sensitive' => null,
|
|
|
|
'spoiler_text' => $parameters['item']['title'] ?? '',
|
2022-02-12 18:27:58 +01:00
|
|
|
'visibility' => $visibility[$parameters['item']['private'] ?? 1],
|
2021-07-29 10:34:31 +00:00
|
|
|
'scheduled_at' => $this->scheduled_at,
|
|
|
|
'poll' => null,
|
|
|
|
'idempotency' => null,
|
2021-07-30 13:22:06 +00:00
|
|
|
'in_reply_to_id' => $in_reply_to_id,
|
2021-07-29 10:34:31 +00:00
|
|
|
'application_id' => ''
|
|
|
|
];
|
|
|
|
|
2021-07-30 22:39:13 +00:00
|
|
|
$this->media_attachments = $media_attachments;
|
2021-07-29 10:34:31 +00:00
|
|
|
}
|
|
|
|
}
|