]> git.mxchange.org Git - friendica.git/commitdiff
Throw exception when item doesn't exist in Factory\Api\Mastodon\Status->createFromUriId
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 28 Dec 2020 02:15:21 +0000 (21:15 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 28 Dec 2020 02:15:21 +0000 (21:15 -0500)
- Address https://github.com/friendica/friendica/issues/9250#issuecomment-750464977

src/Factory/Api/Mastodon/Status.php

index cd468a5fbdf0525e6fe4606cd7d785b64ff608c1..e1c11de6cb1c8ffbb1ecf8d7fbef512d49e85935 100644 (file)
@@ -61,6 +61,10 @@ class Status extends BaseFactory
        public function createFromUriId(int $uriId, $uid = 0)
        {
                $item = Item::selectFirst([], ['uri-id' => $uriId, 'uid' => $uid]);
+               if (!$item) {
+                       throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.'));
+               }
+
                $account = DI::mstdnAccount()->createFromContactId($item['author-id']);
 
                $counts = new \Friendica\Object\Api\Mastodon\Status\Counts(