mirror of
https://github.com/friendica/friendica
synced 2024-11-10 03:42:53 +00:00
API: Fixed the bookmarking
This commit is contained in:
parent
00aa905c15
commit
38fbe281f9
2 changed files with 26 additions and 2 deletions
|
@ -42,7 +42,7 @@ class Bookmark extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
$item = Post::selectFirst(['uid', 'id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
@ -51,6 +51,18 @@ class Bookmark extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked'));
|
||||
}
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
$stored = Item::storeForUserByUriId($this->parameters['id'], $uid);
|
||||
if (!empty($stored)) {
|
||||
$item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
} else {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
Item::update(['starred' => true], ['id' => $item['id']]);
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
|
||||
|
|
|
@ -42,7 +42,7 @@ class Unbookmark extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity();
|
||||
}
|
||||
|
||||
$item = Post::selectFirstForUser($uid, ['id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
$item = Post::selectFirst(['uid', 'id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
|
@ -51,6 +51,18 @@ class Unbookmark extends BaseApi
|
|||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked'));
|
||||
}
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
$stored = Item::storeForUserByUriId($this->parameters['id'], $uid);
|
||||
if (!empty($stored)) {
|
||||
$item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
} else {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
}
|
||||
}
|
||||
|
||||
Item::update(['starred' => false], ['id' => $item['id']]);
|
||||
|
||||
System::jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid)->toArray());
|
||||
|
|
Loading…
Reference in a new issue