]> BookStack Code Mirror - bookstack/blobdiff - app/Activity/CommentRepo.php
Comments: Added back-end content reference handling
[bookstack] / app / Activity / CommentRepo.php
index 3336e17e98831a21ca02dd255182c4c706e458d3..c488350ca24aadf13e6e006961d1953089b92793 100644 (file)
@@ -20,7 +20,7 @@ class CommentRepo
     /**
      * Create a new comment on an entity.
      */
-    public function create(Entity $entity, string $html, ?int $parent_id): Comment
+    public function create(Entity $entity, string $html, ?int $parent_id, string $content_ref): Comment
     {
         $userId = user()->id;
         $comment = new Comment();
@@ -30,6 +30,7 @@ class CommentRepo
         $comment->updated_by = $userId;
         $comment->local_id = $this->getNextLocalId($entity);
         $comment->parent_id = $parent_id;
+        $comment->content_ref = preg_match('/^bkmrk-(.*?):\d+:(\d*-\d*)?$/', $content_ref) === 1 ? $content_ref : '';
 
         $entity->comments()->save($comment);
         ActivityService::add(ActivityType::COMMENT_CREATE, $comment);