diff --git a/src/Factory/Api/Mastodon/ScheduledStatus.php b/src/Factory/Api/Mastodon/ScheduledStatus.php index f0d846fc00..ce79cc8022 100644 --- a/src/Factory/Api/Mastodon/ScheduledStatus.php +++ b/src/Factory/Api/Mastodon/ScheduledStatus.php @@ -45,7 +45,7 @@ class ScheduledStatus extends BaseFactory * @return \Friendica\Object\Api\Mastodon\ScheduledStatus * @throws HTTPException\InternalServerErrorException */ - public function createFromId(int $id, int $uid): \Friendica\Object\Api\Mastodon\ScheduledStatus + public function createFromDelayedPostId(int $id, int $uid): \Friendica\Object\Api\Mastodon\ScheduledStatus { $delayed_post = $this->dba->selectFirst('delayed-post', [], ['id' => $id, 'uid' => $uid]); if (empty($delayed_post)) { @@ -53,6 +53,9 @@ class ScheduledStatus extends BaseFactory } $parameters = Post\Delayed::getParametersForid($delayed_post['id']); + if (empty($parameters)) { + throw new HTTPException\NotFoundException('Scheduled status with ID ' . $id . ' not found for user ' . $uid . '.'); + } return new \Friendica\Object\Api\Mastodon\ScheduledStatus($delayed_post, $parameters); } diff --git a/src/Module/Api/Mastodon/ScheduledStatuses.php b/src/Module/Api/Mastodon/ScheduledStatuses.php index 5e7f4b9547..fab70738f0 100644 --- a/src/Module/Api/Mastodon/ScheduledStatuses.php +++ b/src/Module/Api/Mastodon/ScheduledStatuses.php @@ -72,7 +72,7 @@ class ScheduledStatuses extends BaseApi $uid = self::getCurrentUserID(); if (isset($parameters['id'])) { - System::jsonExit(DI::mstdnScheduledStatus()->createFromId($parameters['id'], $uid)->toArray()); + System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($parameters['id'], $uid)->toArray()); } $request = self::getRequest([ @@ -104,7 +104,7 @@ class ScheduledStatuses extends BaseApi $statuses = []; while ($post = DBA::fetch($posts)) { self::setBoundaries($post['id']); - $statuses[] = DI::mstdnScheduledStatus()->createFromId($post['id'], $uid); + $statuses[] = DI::mstdnScheduledStatus()->createFromDelayedPostId($post['id'], $uid); } DBA::close($posts); diff --git a/src/Module/Api/Mastodon/Statuses.php b/src/Module/Api/Mastodon/Statuses.php index 40bbca0cf0..cd6bbda3f8 100644 --- a/src/Module/Api/Mastodon/Statuses.php +++ b/src/Module/Api/Mastodon/Statuses.php @@ -190,7 +190,7 @@ class Statuses extends BaseApi if (empty($id)) { DI::mstdnError()->InternalError(); } - System::jsonExit(DI::mstdnScheduledStatus()->createFromId($id, $uid)->toArray()); + System::jsonExit(DI::mstdnScheduledStatus()->createFromDelayedPostId($id, $uid)->toArray()); } $id = Item::insert($item, true); diff --git a/src/Object/Api/Mastodon/ScheduledStatus.php b/src/Object/Api/Mastodon/ScheduledStatus.php index f63ba8db51..473cd99a54 100644 --- a/src/Object/Api/Mastodon/ScheduledStatus.php +++ b/src/Object/Api/Mastodon/ScheduledStatus.php @@ -55,7 +55,8 @@ class ScheduledStatus extends BaseDataTransferObject /** * Creates a status record from a delayed-post record. * - * @param array $delayed_post + * @param array $delayed_post Record with the delayed post + * @param array $parameters Parameters for the workerqueue entry for the delayed post * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public function __construct(array $delayed_post, array $parameters)