Fix Mastodon API bookmark, mute, pin, reblog EPs temporarily by checking if blog in post func

This commit is contained in:
Hank Grabowski 2023-06-16 15:31:39 -04:00 committed by Hypolite Petovan
parent 7a556d1588
commit b0fe1927d5
8 changed files with 34 additions and 10 deletions

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}

View 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());
}
}