]> git.mxchange.org Git - friendica.git/commitdiff
Added permission check
authorMichael <heluecht@pirati.ca>
Tue, 20 Jul 2021 21:45:42 +0000 (21:45 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 20 Jul 2021 21:45:42 +0000 (21:45 +0000)
src/Factory/Api/Mastodon/Status.php
src/Module/Api/Mastodon/Statuses/Card.php

index 69257d652b10019e193d77f3d1759e3901667998..42f02a725c2435cf312f5841344ffba0674ae2fd 100644 (file)
@@ -79,7 +79,7 @@ class Status extends BaseFactory
                        'thr-parent-id', 'parent-author-id', 'language', 'uri', 'plink', 'private', 'vid', 'gravity'];
                $item = Post::selectFirst($fields, ['uri-id' => $uriId, 'uid' => [0, $uid]], ['order' => ['uid' => true]]);
                if (!$item) {
-                       throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . 'not found' . ($uid ? ' for user ' . $uid : '.'));
+                       throw new HTTPException\NotFoundException('Item with URI ID ' . $uriId . ' not found' . ($uid ? ' for user ' . $uid : '.'));
                }
 
                $account = $this->mstdnAccountFactory->createFromContactId($item['author-id']);
index 48facb2f0a8f01a66245c5ee1df55fba90d954c2..2fe48255442d0b696fafc1f780bfa5971ba91a17 100644 (file)
@@ -23,7 +23,9 @@ namespace Friendica\Module\Api\Mastodon\Statuses;
 
 use Friendica\Core\System;
 use Friendica\DI;
+use Friendica\Model\Post;
 use Friendica\Module\BaseApi;
+use Friendica\Network\HTTPException;
 
 /**
  * @see https://docs.joinmastodon.org/methods/statuses/
@@ -42,12 +44,12 @@ class Card extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $request = self::getRequest([
-                       'limit'    => 40, // Maximum number of results to return. Defaults to 40.
-               ]);
-
                $id = $parameters['id'];
 
+               if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
+                       throw new HTTPException\NotFoundException('Item with URI ID ' . $id . ' not found' . ($uid ? ' for user ' . $uid : '.'));
+               }
+
                $card = DI::mstdnCard()->createFromUriId($id);
 
                System::jsonExit($card->toArray());