]> BookStack Code Mirror - bookstack/blobdiff - app/Activity/Controllers/CommentController.php
Comments: Added archive endpoints, messages, Js actions and tests
[bookstack] / app / Activity / Controllers / CommentController.php
index 2620800678406b5b0607a3cd551849cee1b74d8a..7a290ebabc526969ae38232be72982c8af953f30 100644 (file)
@@ -75,6 +75,42 @@ class CommentController extends Controller
         ]);
     }
 
+    /**
+     * Mark a comment as archived.
+     */
+    public function archive(int $id)
+    {
+        $comment = $this->commentRepo->getById($id);
+        if (!userCan('comment-update', $comment) && !userCan('comment-delete', $comment)) {
+            $this->showPermissionError();
+        }
+
+        $this->commentRepo->archive($comment);
+
+        return view('comments.comment', [
+            'comment' => $comment,
+            'readOnly' => false,
+        ]);
+    }
+
+    /**
+     * Unmark a comment as archived.
+     */
+    public function unarchive(int $id)
+    {
+        $comment = $this->commentRepo->getById($id);
+        if (!userCan('comment-update', $comment) && !userCan('comment-delete', $comment)) {
+            $this->showPermissionError();
+        }
+
+        $this->commentRepo->unarchive($comment);
+
+        return view('comments.comment', [
+            'comment' => $comment,
+            'readOnly' => false,
+        ]);
+    }
+
     /**
      * Delete a comment from the system.
      */