]> git.mxchange.org Git - friendica.git/commitdiff
Fix id/uri-id chaos in API calls
authorMichael <heluecht@pirati.ca>
Sat, 8 Jul 2023 07:55:18 +0000 (07:55 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 8 Jul 2023 07:55:18 +0000 (07:55 +0000)
src/Module/Api/Mastodon/Statuses/Bookmark.php
src/Module/Api/Mastodon/Statuses/Card.php
src/Module/Api/Mastodon/Statuses/FavouritedBy.php
src/Module/Api/Mastodon/Statuses/Mute.php
src/Module/Api/Mastodon/Statuses/Pin.php
src/Module/Api/Mastodon/Statuses/RebloggedBy.php
src/Module/Api/Mastodon/Statuses/Unbookmark.php
src/Module/Api/Mastodon/Statuses/Unmute.php
src/Module/Api/Mastodon/Statuses/Unpin.php

index 255b459c333252daf134a20b944cd8732f623d23..59c61f9913a1fe28e47ac72fb97c57620640979b 100644 (file)
@@ -42,7 +42,7 @@ class Bookmark extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginal(['uid', 'id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
+               $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
@@ -52,7 +52,7 @@ class Bookmark extends BaseApi
                }
 
                if ($item['uid'] == 0) {
-                       $stored = Item::storeForUserByUriId($item['id'], $uid, ['post-reason' => Item::PR_ACTIVITY]);
+                       $stored = Item::storeForUserByUriId($item['uri-id'], $uid, ['post-reason' => Item::PR_ACTIVITY]);
                        if (!empty($stored)) {
                                $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
                                if (!DBA::isResult($item)) {
index 6d29ee879e2cefe3f33c30d5c18ff757a778188f..3e973d9bbad795a211c848a3153dc1839a49b5fe 100644 (file)
@@ -43,11 +43,11 @@ class Card extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               if (!$post = Post::selectOriginal(['id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
+               if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
                        throw new HTTPException\NotFoundException('Item with URI ID ' . $this->parameters['id'] . ' not found' . ($uid ? ' for user ' . $uid : '.'));
                }
 
-               $card = DI::mstdnCard()->createFromUriId($post['id']);
+               $card = DI::mstdnCard()->createFromUriId($post['uri-id']);
 
                System::jsonExit($card->toArray());
        }
index 326e48d823f54bb052b7801339d9134810302076..fcfb97d92673ac2cf0324b42a2aadf9108638f2e 100644 (file)
@@ -44,11 +44,11 @@ class FavouritedBy extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               if (!$post = Post::selectOriginal(['id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
+               if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
                        DI::mstdnError()->RecordNotFound();
                }
 
-               $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE, 'deleted' => false]);
+               $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE, 'deleted' => false]);
 
                $accounts = [];
 
index 0c1068490c463a5477eced1a66d40572bac2f46b..1f00d39d0e2f61e6af29cc240b3be24bbd93e3fc 100644 (file)
@@ -42,7 +42,7 @@ class Mute extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginalForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
+               $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
@@ -51,7 +51,7 @@ class Mute extends BaseApi
                        DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
                }
 
-               Post\ThreadUser::setIgnored($item['id'], $uid, true);
+               Post\ThreadUser::setIgnored($item['uri-id'], $uid, true);
 
                System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
        }
index d092b4255f1f4020e563a9e45d990da468fbf1d6..33a0116eb1162941ba7376057e89557a5cd723d0 100644 (file)
@@ -41,12 +41,12 @@ class Pin extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginalForUser($uid, ['id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
+               $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
 
-               Post\Collection::add($item['id'], Post\Collection::FEATURED, $item['author-id'], $uid);
+               Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid);
 
                System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
        }
index b225d17439c1d28a181024102072ae98d147bb60..a12975a8be244e3affc4d543875b6acf12d43903 100644 (file)
@@ -44,11 +44,11 @@ class RebloggedBy extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               if (!$post = Post::selectOriginal(['id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
+               if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
                        DI::mstdnError()->RecordNotFound();
                }
 
-               $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
+               $activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
 
                $accounts = [];
 
index 4f6db11fd33b60bc94bcd6dc1c971829e3656ce9..f95fd9445d83ca88d4ada923fc281fd65f94b35d 100644 (file)
@@ -42,7 +42,7 @@ class Unbookmark extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginal(['uid', 'id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
+               $item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
@@ -52,7 +52,7 @@ class Unbookmark extends BaseApi
                }
 
                if ($item['uid'] == 0) {
-                       $stored = Item::storeForUserByUriId($item['id'], $uid, ['post-reason' => Item::PR_ACTIVITY]);
+                       $stored = Item::storeForUserByUriId($item['uri-id'], $uid, ['post-reason' => Item::PR_ACTIVITY]);
                        if (!empty($stored)) {
                                $item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
                                if (!DBA::isResult($item)) {
index b7a24beed24adba1a5b29d263068dd3a4405a795..2285422cac3a09a0a6dcdf28ce007ee4da0fe2be 100644 (file)
@@ -42,7 +42,7 @@ class Unmute extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginalForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
+               $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
@@ -51,7 +51,7 @@ class Unmute extends BaseApi
                        DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
                }
 
-               Post\ThreadUser::setIgnored($item['id'], $uid, false);
+               Post\ThreadUser::setIgnored($item['uri-id'], $uid, false);
 
                System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
        }
index 523ce4d554d416290160ddf86ae9abb52af128a3..c80582d15a9f3f5cda7ee02a6a30c99a20335d81 100644 (file)
@@ -41,12 +41,12 @@ class Unpin extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginalForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
+               $item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
 
-               Post\Collection::remove($item['id'], Post\Collection::FEATURED, $uid);
+               Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid);
 
                System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
        }