Commit 4ecb42f7 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

fix(fediverse): do not cache remote action form + fix typo on post routes for passing post uuid

+ remove unnecessary session->start() directive
parent 3189f122
Loading
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ class Cache extends BaseConfig
     *    true  = Enabled, take all query parameters into account.
     *            Please be aware that this may result in numerous cache
     *            files generated for the same page over and over again.
     *    array('q') = Enabled, but only take into account the specified list
     *    ['q'] = Enabled, but only take into account the specified list
     *                 of query parameters.
     *
     * @var boolean|string[]
@@ -97,6 +97,7 @@ class Cache extends BaseConfig
     * A string of reserved characters that will not be allowed in keys or tags.
     * Strings that violate this restriction will cause handlers to throw.
     * Default: {}()/\@:
     *
     * Note: The default set is required for PSR-6 compliance.
     */
    public string $reservedCharacters = '{}()/\@:';
+2 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@ use CodeIgniter\Router\RouteCollection;

/**
 * @var RouteCollection $routes
/**
 *
 * --------------------------------------------------------------------
 * Placeholder definitions
 * --------------------------------------------------------------------
@@ -232,7 +232,7 @@ $routes->group('@(:podcastHandle)', static function ($routes): void {
                ],
                'application/ld+json; profile="https://www.w3.org/ns/activitystreams' => [
                    'namespace'         => 'Modules\Fediverse\Controllers',
                    'controller-method' => 'PostController::index\$2',
                    'controller-method' => 'PostController::index/$2',
                ],
            ],
            'filter' => 'allow-cors',
+0 −1
Original line number Diff line number Diff line
@@ -133,7 +133,6 @@ class EpisodeAudioController extends Controller
        }

        $session = Services::session();
        $session->start();

        $serviceName = '';
        if ($this->request->getGet('_from')) {
+1 −1
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ class EpisodeController extends BaseController
        }

        $session = Services::session();
        $session->start();

        if (service('superglobals')->server('HTTP_REFERER') !== null) {
            $session->set('embed_domain', parse_url(service('superglobals')->server('HTTP_REFERER'), PHP_URL_HOST));
        }
+10 −21
Original line number Diff line number Diff line
@@ -249,12 +249,6 @@ class PostController extends FediversePostController
            $this->registerPodcastWebpageHit($this->podcast->id);
        }

        $cacheName = implode(
            '_',
            array_filter(['page', "post#{$this->post->id}", "remote_{$action}", service('request') ->getLocale()]),
        );

        if (! ($cachedView = cache($cacheName))) {
        $data = [
            'metatags' => get_remote_actions_metatags($this->post, $action),
            'podcast'  => $this->podcast,
@@ -265,12 +259,7 @@ class PostController extends FediversePostController

        helper('form');

            return view('post/remote_action', $data, [
                'cache'      => DECADE,
                'cache_name' => $cacheName,
            ]);
        }

        return (string) $cachedView;
        // NO VIEW CACHING: form has a CSRF token which should change on each request
        return view('post/remote_action', $data);
    }
}
Loading