]> BookStack Code Mirror - bookstack/blobdiff - app/Activity/CommentRepo.php
Comments: Added archive endpoints, messages, Js actions and tests
[bookstack] / app / Activity / CommentRepo.php
index c488350ca24aadf13e6e006961d1953089b92793..866368ee64963a0f5a78ffd1d29931885d58c898 100644 (file)
@@ -53,6 +53,33 @@ class CommentRepo
         return $comment;
     }
 
+
+    /**
+     * Archive an existing comment.
+     */
+    public function archive(Comment $comment): Comment
+    {
+        $comment->archived = true;
+        $comment->save();
+
+        ActivityService::add(ActivityType::COMMENT_UPDATE, $comment);
+
+        return $comment;
+    }
+
+    /**
+     * Un-archive an existing comment.
+     */
+    public function unarchive(Comment $comment): Comment
+    {
+        $comment->archived = false;
+        $comment->save();
+
+        ActivityService::add(ActivityType::COMMENT_UPDATE, $comment);
+
+        return $comment;
+    }
+
     /**
      * Delete a comment from the system.
      */