X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FStarred.php;h=0f111b21e0198f51185aef8b650044d37837bd0d;hb=6cbfa5b862ce7a241fd4339129749f87dc19760c;hp=5c79c4fac87344cb99ac0a9686260dc9cd8101e9;hpb=abe6724629b851c6cce965a0aa03658b9dae8c62;p=friendica.git diff --git a/src/Module/Starred.php b/src/Module/Starred.php index 5c79c4fac8..0f111b21e0 100644 --- a/src/Module/Starred.php +++ b/src/Module/Starred.php @@ -3,32 +3,32 @@ namespace Friendica\Module; use Friendica\BaseModule; +use Friendica\DI; use Friendica\Model\Item; -use Friendica\Core\System; /** * Toggle starred items */ class Starred extends BaseModule { - public static function rawContent($parameters) + public static function rawContent(array $parameters = []) { if (!local_user()) { - exit(); + throw new \Friendica\Network\HTTPException\ForbiddenException(); } if (empty($parameters['item'])) { - exit; - } else { - $itemId = intval($parameters['item']); + throw new \Friendica\Network\HTTPException\BadRequestException(); } + $itemId = intval($parameters['item']); + $item = Item::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]); if (empty($item)) { - exit(); + throw new \Friendica\Network\HTTPException\NotFoundException(); } - $starred = !$item['starred']; + $starred = !(bool)$item['starred']; Item::update(['starred' => $starred], ['id' => $itemId]); @@ -36,10 +36,11 @@ class Starred extends BaseModule $returnPath = $_REQUEST['return'] ?? ''; if (!empty($returnPath)) { $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand'; - self::getApp()->internalRedirect($returnPath . $rand); + DI::baseUrl()->redirect($returnPath . $rand); } // the json doesn't really matter, it will either be 0 or 1 - System::jsonExit($starred); + echo json_encode((int)$starred); + exit(); } }