Fixed Mark As Read on forum index not working.
This commit is contained in:
parent
b451e87fa5
commit
5a495ec472
3 changed files with 7 additions and 10 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
{% if current_user is defined %}
|
||||
<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>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in a new issue