From fce622b5b1959892b6f6ea94bfe3a1c4eb52d8dd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 14 Oct 2023 11:12:05 -0400 Subject: Added comment replying --- app/controllers/admin/comments_controller.rb | 4 ++++ app/controllers/comments_controller.rb | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/admin/comments_controller.rb b/app/controllers/admin/comments_controller.rb index ccde3e6..9958232 100644 --- a/app/controllers/admin/comments_controller.rb +++ b/app/controllers/admin/comments_controller.rb @@ -14,6 +14,10 @@ class Admin::CommentsController < Admin::AdminController @comment.status = :published @comment.save! + if @comment.reply_to and @comment.reply_to.email != @comment.blog.user.email and @comment.reply_to.email != current_user.email + CommentMailer.with(comment: @comment).reply_comment_email.deliver_later + end + flash.notice = "Comment successfully published." redirect_to pending_admin_comments_url end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index a444dba..2f3117f 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -46,6 +46,10 @@ class CommentsController < ApplicationController if @comment.status == :published CommentMailer.with(comment: @comment).new_comment_email.deliver_later + + if @comment.reply_to and @comment.reply_to.email != @comment.blog.user.email + CommentMailer.with(comment: @comment).reply_comment_email.deliver_later + end else CommentMailer.with(comment: @comment).new_pending_comment_email.deliver_later end @@ -60,6 +64,6 @@ class CommentsController < ApplicationController private def comment_params - params.require(:comment).permit(:username, :email, :website, :body) + params.require(:comment).permit(:username, :email, :website, :body, :reply_to_id) end end -- cgit 1.4.1