3 namespace Friendica\Module;
5 use Friendica\BaseModule;
7 use Friendica\Model\Item;
8 use Friendica\Core\Session;
9 use Friendica\Network\HTTPException;
10 use Friendica\Util\Strings;
13 * Performs a like and optionally redirects to a return path
15 class Like extends BaseModule
17 public static function rawContent(array $parameters = [])
19 if (!Session::isAuthenticated()) {
20 throw new HTTPException\ForbiddenException();
23 $verb = Strings::escapeTags(trim($_GET['verb']));
31 // @TODO: Replace with parameter from router
32 $itemId = (($app->argc > 1) ? Strings::escapeTags(trim($app->argv[1])) : 0);
34 if (!Item::performLike($itemId, $verb)) {
35 throw new HTTPException\BadRequestException();
38 // Decide how to return. If we were called with a 'return' argument,
39 // then redirect back to the calling page. If not, just quietly end
40 $returnPath = $_REQUEST['return'] ?? '';
42 if (!empty($returnPath)) {
43 $rand = '_=' . time();
44 if (strpos($returnPath, '?')) {
50 DI::baseUrl()->redirect($returnPath . $rand);