diff --git a/public_html/dispatch.php b/public_html/dispatch.php
index a8fb4753..ab005763 100644
--- a/public_html/dispatch.php
+++ b/public_html/dispatch.php
@@ -93,6 +93,7 @@ $postValidation =
\Chibi\Router::register(['PostController', 'unhideAction'], 'POST', '/post/{id}/unhide', $postValidation);
\Chibi\Router::register(['PostController', 'removeFavoriteAction'], 'POST', '/post/{id}/rem-fav', $postValidation);
\Chibi\Router::register(['PostController', 'addFavoriteAction'], 'POST', '/post/{id}/add-fav', $postValidation);
+\Chibi\Router::register(['PostController', 'scoreAction'], 'POST', '/post/{id}/score/{score}', $postValidation);
\Chibi\Router::register(['CommentController', 'listView'], 'GET', '/comments');
\Chibi\Router::register(['CommentController', 'listView'], 'GET', '/comments/{page}', ['page' => '\d+']);
@@ -107,7 +108,6 @@ foreach (['GET', 'POST'] as $method)
\Chibi\Router::register(['PostController', 'retrieveAction'], $method, '/post/{name}/retrieve', $postValidation);
\Chibi\Router::register(['PostController', 'thumbAction'], $method, '/post/{name}/thumb', $postValidation);
\Chibi\Router::register(['PostController', 'featureAction'], $method, '/post/{id}/feature', $postValidation);
- \Chibi\Router::register(['PostController', 'scoreAction'], $method, '/post/{id}/score/{score}', $postValidation);
$tagValidation =
[
diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php
index 31103b2e..74255872 100644
--- a/src/Controllers/PostController.php
+++ b/src/Controllers/PostController.php
@@ -207,15 +207,9 @@ class PostController
public function scoreAction($id, $score)
{
- $context = getContext();
- $post = PostModel::findByIdOrName($id);
- Access::assert(Privilege::ScorePost, Access::getIdentity($post->getUploader()));
- Access::assertAuthentication();
-
- if (!InputHelper::get('submit'))
- return;
-
- UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score);
+ Api::run(new ScorePostJob(), [
+ ScorePostJob::POST_ID => $id,
+ ScorePostJob::SCORE => $score]);
}
public function featureAction($id)
diff --git a/src/Jobs/ScorePostJob.php b/src/Jobs/ScorePostJob.php
new file mode 100644
index 00000000..5e8c4211
--- /dev/null
+++ b/src/Jobs/ScorePostJob.php
@@ -0,0 +1,32 @@
+post;
+ $score = intval($this->getArgument(self::SCORE));
+
+ UserModel::updateUserScore(Auth::getCurrentUser(), $post, $score);
+ }
+
+ public function requiresPrivilege()
+ {
+ return
+ [
+ Privilege::ScorePost,
+ Access::getIdentity($this->post->getUploader())
+ ];
+ }
+
+ public function requiresAuthentication()
+ {
+ return true;
+ }
+
+ public function requiresConfirmedEmail()
+ {
+ return false;
+ }
+}