From 93263a820dd06997030f1cc9e65ed52bc99ea3d1 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 30 Jul 2021 10:24:08 +0000 Subject: [PATCH] Function renamed, documentation added --- src/Factory/Api/Mastodon/ScheduledStatus.php | 5 ++++- src/Module/Api/Mastodon/ScheduledStatuses.php | 4 ++-- src/Module/Api/Mastodon/Statuses.php | 2 +- src/Object/Api/Mastodon/ScheduledStatus.php | 3 ++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Factory/Api/Mastodon/ScheduledStatus.php b/src/Factory/Api/Mastodon/ScheduledStatus.php index f0d846fc0..ce79cc802 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 5e7f4b954..fab70738f 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 40bbca0cf..cd6bbda3f 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 f63ba8db5..473cd99a5 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)