3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Model\Item;
11 class Starred extends BaseModule
13 public static function rawContent(array $parameters = [])
16 throw new \Friendica\Network\HTTPException\ForbiddenException();
19 if (empty($parameters['item'])) {
20 throw new \Friendica\Network\HTTPException\BadRequestException();
23 $itemId = intval($parameters['item']);
25 $item = Item::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]);
27 throw new \Friendica\Network\HTTPException\NotFoundException();
30 $starred = !(bool)$item['starred'];
32 Item::update(['starred' => $starred], ['id' => $itemId]);
34 // See if we've been passed a return path to redirect to
35 $returnPath = $_REQUEST['return'] ?? '';
36 if (!empty($returnPath)) {
37 $rand = '_=' . time() . (strpos($returnPath, '?') ? '&' : '?') . 'rand';
38 self::getApp()->internalRedirect($returnPath . $rand);
41 // the json doesn't really matter, it will either be 0 or 1
42 echo json_encode((int)$starred);