3 namespace Friendica\Module;
5 use Friendica\BaseModule;
6 use Friendica\Model\Item;
7 use Friendica\Core\Session;
8 use Friendica\Network\HTTPException;
9 use Friendica\Util\Strings;
12 * Performs a like and optionally redirects to a return path
14 class Like extends BaseModule
16 public static function rawContent(array $parameters = [])
18 if (!Session::isAuthenticated()) {
19 throw new HTTPException\ForbiddenException();
22 $verb = Strings::escapeTags(trim($_GET['verb']));
28 $app = self::getApp();
30 // @TODO: Replace with parameter from router
31 $itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);
33 if (!Item::performLike($itemId, $verb)) {
34 throw new HTTPException\BadRequestException();
37 // Decide how to return. If we were called with a 'return' argument,
38 // then redirect back to the calling page. If not, just quietly end
39 $returnPath = $_REQUEST['return'] ?? '';
41 if (!empty($returnPath)) {
42 $rand = '_=' . time();
43 if (strpos($returnPath, '?')) {
49 $app->internalRedirect($returnPath . $rand);