Fix Mastodon API fav/unfav temporarily by checking if blog in post func

This commit is contained in:
Hank Grabowski 2023-06-16 14:48:12 -04:00 committed by Hypolite Petovan
parent 532a46d188
commit 7a556d1588
2 changed files with 10 additions and 4 deletions

View file

@ -42,13 +42,16 @@ class Favourite extends BaseApi
DI::mstdnError()->UnprocessableEntity(); DI::mstdnError()->UnprocessableEntity();
} }
$item = Post::selectOriginalForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound(); DI::mstdnError()->RecordNotFound();
} }
Item::performActivity($item['id'], 'like', $uid); Item::performActivity($item['id'], 'like', $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());
} }
} }

View file

@ -42,13 +42,16 @@ class Unfavourite extends BaseApi
DI::mstdnError()->UnprocessableEntity(); DI::mstdnError()->UnprocessableEntity();
} }
$item = Post::selectOriginalForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]); $item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
if (!DBA::isResult($item)) { if (!DBA::isResult($item)) {
DI::mstdnError()->RecordNotFound(); DI::mstdnError()->RecordNotFound();
} }
Item::performActivity($item['id'], 'unlike', $uid); Item::performActivity($item['id'], 'unlike', $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());
} }
} }