. * */ namespace Friendica\Factory\Api\Mastodon; use Friendica\BaseFactory; use Friendica\Database\Database; use Friendica\Model\Post; use Friendica\Network\HTTPException; use Psr\Log\LoggerInterface; class ScheduledStatus extends BaseFactory { /** @var Database */ private $dba; public function __construct(LoggerInterface $logger, Database $dba) { parent::__construct($logger); $this->dba = $dba; } /** * @param int $id Id of the delayed post * @param int $uid Post user * * @return \Friendica\Object\Api\Mastodon\ScheduledStatus * @throws HTTPException\InternalServerErrorException */ public function createFromId(int $id, int $uid): \Friendica\Object\Api\Mastodon\ScheduledStatus { $delayed_post = $this->dba->selectFirst('delayed-post', [], ['id' => $id, 'uid' => $uid]); if (empty($delayed_post)) { throw new HTTPException\NotFoundException('Scheduled status with ID ' . $id . ' not found for user ' . $uid . '.'); } $parameters = Post\Delayed::getParametersForid($delayed_post['id']); return new \Friendica\Object\Api\Mastodon\ScheduledStatus($delayed_post, $parameters); } }