From 5a495ec4725bb402572b991a359db77d639cc4ee Mon Sep 17 00:00:00 2001 From: flashwave Date: Mon, 2 Jan 2023 19:50:33 +0000 Subject: [PATCH] Fixed Mark As Read on forum index not working. --- src/Forum/forum.php | 4 ++++ src/Http/Handlers/ForumHandler.php | 11 ++--------- templates/forum/index.twig | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Forum/forum.php b/src/Forum/forum.php index d788741..46fadb2 100644 --- a/src/Forum/forum.php +++ b/src/Forum/forum.php @@ -377,6 +377,10 @@ function forum_timeout(int $forumId, int $userId): int { // $forumId == null marks all forums as read function forum_mark_read(?int $forumId, int $userId): void { + // shitty fix for dumb-ass function signature + if($forumId === 0) + $forumId = null; + if(($forumId !== null && $forumId < 1) || $userId < 1) { return; } diff --git a/src/Http/Handlers/ForumHandler.php b/src/Http/Handlers/ForumHandler.php index e982009..725c206 100644 --- a/src/Http/Handlers/ForumHandler.php +++ b/src/Http/Handlers/ForumHandler.php @@ -29,10 +29,7 @@ final class ForumHandler extends Handler { if(!$request->isFormContent()) return 400; - - $token = $request->getHeaderLine('X-Misuzu-CSRF'); - if(empty($token)) - $token = $request->getBodyParam('_csrf'); + $token = $request->getContent()->getParam('_csrf'); if(empty($token) || !CSRF::validate($token)) return 400; @@ -40,10 +37,6 @@ final class ForumHandler extends Handler { forum_mark_read($forumId, User::getCurrent()->getId()); $redirect = url($forumId ? 'forum-category' : 'forum-index', ['forum' => $forumId]); - if($request->hasHeader('X-Misuzu-XHR')) { - $response->setStatusCode(302); - $response->setHeader('X-Misuzu-Location', $redirect); - } else - $response->redirect($redirect, false); + $response->redirect($redirect, false); } } diff --git a/templates/forum/index.twig b/templates/forum/index.twig index e80ebcc..637e0df 100644 --- a/templates/forum/index.twig +++ b/templates/forum/index.twig @@ -23,7 +23,7 @@ {% if current_user is defined %}
- Mark All Read + Mark All Read
{% endif %} {% else %}