]> git.mxchange.org Git - friendica.git/commitdiff
Fix Mastodon API bookmark, mute, pin, reblog EPs temporarily by checking if blog...
authorHank Grabowski <hankgrabowski@gmail.com>
Fri, 16 Jun 2023 19:31:39 +0000 (15:31 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Wed, 26 Jul 2023 17:12:24 +0000 (19:12 +0200)
src/Module/Api/Mastodon/Statuses/Bookmark.php
src/Module/Api/Mastodon/Statuses/Mute.php
src/Module/Api/Mastodon/Statuses/Pin.php
src/Module/Api/Mastodon/Statuses/Reblog.php
src/Module/Api/Mastodon/Statuses/Unbookmark.php
src/Module/Api/Mastodon/Statuses/Unmute.php
src/Module/Api/Mastodon/Statuses/Unpin.php
src/Module/Api/Mastodon/Statuses/Unreblog.php

index 59c61f9913a1fe28e47ac72fb97c57620640979b..9625b5e122df34eaeae6510e92c4c1043a977e00 100644 (file)
@@ -65,6 +65,9 @@ class Bookmark extends BaseApi
 
                Item::update(['starred' => true], ['id' => $item['id']]);
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }
index 1f00d39d0e2f61e6af29cc240b3be24bbd93e3fc..587999bad7674440cf85903ecb3c849e8c80c3c6 100644 (file)
@@ -53,6 +53,9 @@ class Mute extends BaseApi
 
                Post\ThreadUser::setIgnored($item['uri-id'], $uid, true);
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }
index 33a0116eb1162941ba7376057e89557a5cd723d0..601f82f2d0f5057e48f7f4aad538f2c4650644a0 100644 (file)
@@ -48,6 +48,9 @@ class Pin extends BaseApi
 
                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());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(),$isReblog)->toArray());
        }
 }
index f1922d72712783790608baa61ac142b8f91e20f6..409f8e788f1bc9915f6cf7756f3d51b3b716f8a4 100644 (file)
@@ -45,7 +45,7 @@ class Reblog extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginalForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
+               $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
@@ -58,6 +58,9 @@ class Reblog extends BaseApi
                        Item::performActivity($item['id'], 'announce', $uid);
                }
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }
index f95fd9445d83ca88d4ada923fc281fd65f94b35d..03a3e6f002034ec7cbbf8b78834c1b354d906a2e 100644 (file)
@@ -65,6 +65,9 @@ class Unbookmark extends BaseApi
 
                Item::update(['starred' => false], ['id' => $item['id']]);
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }
index 2285422cac3a09a0a6dcdf28ce007ee4da0fe2be..63cd6d722d09190e78b522ece80b4e233859aa83 100644 (file)
@@ -53,6 +53,9 @@ class Unmute extends BaseApi
 
                Post\ThreadUser::setIgnored($item['uri-id'], $uid, false);
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }
index c80582d15a9f3f5cda7ee02a6a30c99a20335d81..22610f4468a2aa082b16ac66e51a25958e229031 100644 (file)
@@ -48,6 +48,9 @@ class Unpin extends BaseApi
 
                Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid);
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }
index 54a18823a77168bc278777ae7fdb9e95e16e54ff..a1544807f15cc3632a3f9a6267a2d893db419cec 100644 (file)
@@ -44,7 +44,7 @@ class Unreblog extends BaseApi
                        DI::mstdnError()->UnprocessableEntity();
                }
 
-               $item = Post::selectOriginalForUser($uid, ['id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
+               $item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
                if (!DBA::isResult($item)) {
                        DI::mstdnError()->RecordNotFound();
                }
@@ -64,6 +64,9 @@ class Unreblog extends BaseApi
                        Item::performActivity($item['id'], 'unannounce', $uid);
                }
 
-               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes())->toArray());
+               // @TODO Remove once mstdnStatus()->createFromUriId is fixed
+               $isReblog = $item['uri-id'] != $this->parameters['id'];
+
+               System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
        }
 }