Loading app/Config/Routes.php +8 −0 Original line number Diff line number Diff line Loading @@ -426,6 +426,14 @@ $routes->group( 'filter' => 'permission:podcast-manage_publications', ] ); $routes->post( '(:uuid)/reply', 'EpisodeController::attemptCommentReply/$1/$2/$3', [ 'as' => 'comment-attempt-reply', 'filter' => 'permission:podcast-manage_publications', ] ); $routes->post( 'delete', 'EpisodeController::attemptCommentDelete/$1/$2', Loading app/Controllers/Admin/EpisodeController.php +41 −0 Original line number Diff line number Diff line Loading @@ -821,4 +821,45 @@ class EpisodeController extends BaseController // Comment has been successfully created return redirect()->back(); } public function attemptCommentReply(string $commentId): RedirectResponse { // var_dump($commentId); // die(); $rules = [ 'message' => 'required|max_length[500]', ]; if (! $this->validate($rules)) { return redirect() ->back() ->withInput() ->with('errors', $this->validator->getErrors()); } $message = $this->request->getPost('message'); $newReply = new EpisodeComment([ 'actor_id' => interact_as_actor_id(), 'episode_id' => $this->episode->id, 'message' => $message, 'in_reply_to_id' => $commentId, 'created_at' => new Time('now'), 'created_by' => user_id(), ]); $commentModel = new EpisodeCommentModel(); if ( ! $commentModel->addComment($newReply, true) ) { return redirect() ->back() ->withInput() ->with('errors', $commentModel->errors()); } // Reply has been successfully created return redirect()->back(); } } app/Controllers/EpisodeCommentController.php +8 −0 Original line number Diff line number Diff line Loading @@ -170,4 +170,12 @@ class EpisodeCommentController extends BaseController return redirect()->back(); } public function attemptReply(): RedirectResponse { model('LikeModel') ->toggleLike(interact_as_actor(), $this->comment); return redirect()->back(); } } app/Entities/EpisodeComment.php +14 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,20 @@ class EpisodeComment extends UuidEntity return $this->replies; } public function getReplyToComment(): ?self { if ($this->in_reply_to_id === null) { throw new RuntimeException('Comment is not a reply.'); } if ($this->reply_to_comment === null) { $this->reply_to_comment = model('EpisodeCommentModel', false) ->getCommentById($this->in_reply_to_id); } return $this->reply_to_comment; } public function setMessage(string $message): static { helper('activitypub'); Loading app/Language/en/Comment.php +10 −0 Original line number Diff line number Diff line Loading @@ -9,12 +9,22 @@ declare(strict_types=1); */ return [ 'title' => "{actorDisplayName}'s comment for {episodeTitle}", 'back_to_episode' => 'Back to {episodeTitle}', 'form' => [ 'episode_message_placeholder' => 'Write a comment...', 'reply_to_placeholder' => 'Reply to @{actorUsername}', 'submit' => 'Send!', 'submit_reply' => 'Reply', ], 'likes' => '{numberOfLikes, plural, one {# like} other {# likes} }', 'replies' => '{numberOfReplies, plural, one {# reply} other {# replies} }', 'like' => 'Like', 'reply' => 'Reply', 'view_replies' => 'View replies ({numberOfReplies})', Loading Loading
app/Config/Routes.php +8 −0 Original line number Diff line number Diff line Loading @@ -426,6 +426,14 @@ $routes->group( 'filter' => 'permission:podcast-manage_publications', ] ); $routes->post( '(:uuid)/reply', 'EpisodeController::attemptCommentReply/$1/$2/$3', [ 'as' => 'comment-attempt-reply', 'filter' => 'permission:podcast-manage_publications', ] ); $routes->post( 'delete', 'EpisodeController::attemptCommentDelete/$1/$2', Loading
app/Controllers/Admin/EpisodeController.php +41 −0 Original line number Diff line number Diff line Loading @@ -821,4 +821,45 @@ class EpisodeController extends BaseController // Comment has been successfully created return redirect()->back(); } public function attemptCommentReply(string $commentId): RedirectResponse { // var_dump($commentId); // die(); $rules = [ 'message' => 'required|max_length[500]', ]; if (! $this->validate($rules)) { return redirect() ->back() ->withInput() ->with('errors', $this->validator->getErrors()); } $message = $this->request->getPost('message'); $newReply = new EpisodeComment([ 'actor_id' => interact_as_actor_id(), 'episode_id' => $this->episode->id, 'message' => $message, 'in_reply_to_id' => $commentId, 'created_at' => new Time('now'), 'created_by' => user_id(), ]); $commentModel = new EpisodeCommentModel(); if ( ! $commentModel->addComment($newReply, true) ) { return redirect() ->back() ->withInput() ->with('errors', $commentModel->errors()); } // Reply has been successfully created return redirect()->back(); } }
app/Controllers/EpisodeCommentController.php +8 −0 Original line number Diff line number Diff line Loading @@ -170,4 +170,12 @@ class EpisodeCommentController extends BaseController return redirect()->back(); } public function attemptReply(): RedirectResponse { model('LikeModel') ->toggleLike(interact_as_actor(), $this->comment); return redirect()->back(); } }
app/Entities/EpisodeComment.php +14 −0 Original line number Diff line number Diff line Loading @@ -118,6 +118,20 @@ class EpisodeComment extends UuidEntity return $this->replies; } public function getReplyToComment(): ?self { if ($this->in_reply_to_id === null) { throw new RuntimeException('Comment is not a reply.'); } if ($this->reply_to_comment === null) { $this->reply_to_comment = model('EpisodeCommentModel', false) ->getCommentById($this->in_reply_to_id); } return $this->reply_to_comment; } public function setMessage(string $message): static { helper('activitypub'); Loading
app/Language/en/Comment.php +10 −0 Original line number Diff line number Diff line Loading @@ -9,12 +9,22 @@ declare(strict_types=1); */ return [ 'title' => "{actorDisplayName}'s comment for {episodeTitle}", 'back_to_episode' => 'Back to {episodeTitle}', 'form' => [ 'episode_message_placeholder' => 'Write a comment...', 'reply_to_placeholder' => 'Reply to @{actorUsername}', 'submit' => 'Send!', 'submit_reply' => 'Reply', ], 'likes' => '{numberOfLikes, plural, one {# like} other {# likes} }', 'replies' => '{numberOfReplies, plural, one {# reply} other {# replies} }', 'like' => 'Like', 'reply' => 'Reply', 'view_replies' => 'View replies ({numberOfReplies})', Loading