Fixed Mark As Read on forum index not working.

This commit is contained in:
flash 2023-01-02 19:50:33 +00:00
parent b451e87fa5
commit 5a495ec472
3 changed files with 7 additions and 10 deletions

View file

@ -377,6 +377,10 @@ function forum_timeout(int $forumId, int $userId): int {
// $forumId == null marks all forums as read // $forumId == null marks all forums as read
function forum_mark_read(?int $forumId, int $userId): void { 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) { if(($forumId !== null && $forumId < 1) || $userId < 1) {
return; return;
} }

View file

@ -29,10 +29,7 @@ final class ForumHandler extends Handler {
if(!$request->isFormContent()) if(!$request->isFormContent())
return 400; return 400;
$token = $request->getContent()->getParam('_csrf');
$token = $request->getHeaderLine('X-Misuzu-CSRF');
if(empty($token))
$token = $request->getBodyParam('_csrf');
if(empty($token) || !CSRF::validate($token)) if(empty($token) || !CSRF::validate($token))
return 400; return 400;
@ -40,10 +37,6 @@ final class ForumHandler extends Handler {
forum_mark_read($forumId, User::getCurrent()->getId()); forum_mark_read($forumId, User::getCurrent()->getId());
$redirect = url($forumId ? 'forum-category' : 'forum-index', ['forum' => $forumId]); $redirect = url($forumId ? 'forum-category' : 'forum-index', ['forum' => $forumId]);
if($request->hasHeader('X-Misuzu-XHR')) { $response->redirect($redirect, false);
$response->setStatusCode(302);
$response->setHeader('X-Misuzu-Location', $redirect);
} else
$response->redirect($redirect, false);
} }
} }

View file

@ -23,7 +23,7 @@
{% if current_user is defined %} {% if current_user is defined %}
<div class="container forum__actions"> <div class="container forum__actions">
<a href="{{ url('forum-mark-global') }}" class="input__button forum__actions__button" data-msz-method="POST">Mark All Read</a> <a href="{{ url('forum-mark-global') }}" class="input__button forum__actions__button">Mark All Read</a>
</div> </div>
{% endif %} {% endif %}
{% else %} {% else %}