mirror of
https://github.com/friendica/friendica
synced 2025-04-26 22:30:18 +00:00
Mark, file and starring does now work for all items
This commit is contained in:
parent
e146a5983c
commit
473adaf463
10 changed files with 48 additions and 26 deletions
|
@ -22,8 +22,10 @@
|
|||
namespace Friendica\Module\Item;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
|
@ -48,11 +50,25 @@ class Star extends BaseModule
|
|||
|
||||
$itemId = intval($parameters['id']);
|
||||
|
||||
$item = Post::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]);
|
||||
|
||||
$item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]);
|
||||
if (empty($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
$stored = Item::storeForUserByUriId($item['uri-id'], local_user());
|
||||
if (!empty($stored)) {
|
||||
$item = Post::selectFirst(['starred'], ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
$itemId = $stored;
|
||||
} else {
|
||||
throw new HTTPException\NotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
$starred = !(bool)$item['starred'];
|
||||
|
||||
Item::update(['starred' => $starred], ['id' => $itemId]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue