Merge pull request #13175 from HankG/mastodon-api-reshare-fixes
Mastodon api reshare fixes
This commit is contained in:
commit
18c078f8c2
|
@ -65,6 +65,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,18 @@ class Favourite extends BaseApi
|
|||
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)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(),$isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,13 +42,18 @@ class Unfavourite extends BaseApi
|
|||
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)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
||||
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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,6 +53,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,11 @@ 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 so that it returns posts not reshared posts if given an ID to an original post that has been reshared
|
||||
// Introduced in this PR: https://github.com/friendica/friendica/pull/13175
|
||||
// Issue tracking the behavior of createFromUriId: https://github.com/friendica/friendica/issues/13350
|
||||
$isReblog = $item['uri-id'] != $this->parameters['id'];
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), $isReblog)->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ class Status extends BaseDataTransferObject
|
|||
*/
|
||||
public function __construct(array $item, Account $account, Counts $counts, UserAttributes $userAttributes, bool $sensitive, Application $application, array $mentions, array $tags, Card $card, array $attachments, array $in_reply, array $reblog, FriendicaExtension $friendica, array $quote = null, array $poll = null)
|
||||
{
|
||||
$reblogged = !empty($reblog);
|
||||
$this->id = (string)$item['uri-id'];
|
||||
$this->created_at = DateTimeFormat::utc($item['created'], DateTimeFormat::JSON);
|
||||
$this->edited_at = DateTimeFormat::utc($item['edited'], DateTimeFormat::JSON);
|
||||
|
@ -135,26 +136,26 @@ class Status extends BaseDataTransferObject
|
|||
|
||||
$this->uri = $item['uri'];
|
||||
$this->url = $item['plink'] ?? null;
|
||||
$this->replies_count = $counts->replies;
|
||||
$this->reblogs_count = $counts->reblogs;
|
||||
$this->favourites_count = $counts->favourites;
|
||||
$this->replies_count = $reblogged ? 0 : $counts->replies;
|
||||
$this->reblogs_count = $reblogged ? 0 : $counts->reblogs;
|
||||
$this->favourites_count = $reblogged ? 0 : $counts->favourites;
|
||||
$this->favourited = $userAttributes->favourited;
|
||||
$this->reblogged = $userAttributes->reblogged;
|
||||
$this->muted = $userAttributes->muted;
|
||||
$this->bookmarked = $userAttributes->bookmarked;
|
||||
$this->pinned = $userAttributes->pinned;
|
||||
$this->content = BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API);
|
||||
$this->content = $reblogged ? '' : BBCode::convertForUriId($item['uri-id'], BBCode::setMentionsToNicknames($item['raw-body'] ?? $item['body']), BBCode::MASTODON_API);
|
||||
$this->reblog = $reblog;
|
||||
$this->quote = $quote;
|
||||
$this->application = $application->toArray();
|
||||
$this->account = $account->toArray();
|
||||
$this->media_attachments = $attachments;
|
||||
$this->mentions = $mentions;
|
||||
$this->tags = $tags;
|
||||
$this->emojis = [];
|
||||
$this->card = $card->toArray() ?: null;
|
||||
$this->poll = $poll;
|
||||
$this->friendica = $friendica;
|
||||
$this->media_attachments = $reblogged ? [] : $attachments;
|
||||
$this->mentions = $reblogged ? [] : $mentions;
|
||||
$this->tags = $reblogged ? [] : $tags;
|
||||
$this->emojis = $reblogged ? [] : [];
|
||||
$this->card = $reblogged ? null : ($card->toArray() ?: null);
|
||||
$this->poll = $reblogged ? null : $poll;
|
||||
$this->friendica = $reblogged ? null : $friendica;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user