prevents users to receive email notifications about own comments and replies

This commit is contained in:
David Gil
2015-09-10 14:16:45 +02:00
parent 8ed434cc8b
commit d9300f1c10
4 changed files with 89 additions and 48 deletions

View File

@@ -7,10 +7,7 @@ class CommentsController < ApplicationController
respond_to :html, :js
def create
if @comment.save
Mailer.comment(@comment).deliver_later if email_on_debate_comment?
Mailer.reply(@comment).deliver_later if email_on_comment_reply?
else
unless @comment.save
render :new
end
end
@@ -55,14 +52,6 @@ class CommentsController < ApplicationController
@commentable = Comment.find_commentable(comment_params[:commentable_type], comment_params[:commentable_id])
end
def email_on_debate_comment?
@comment.commentable.author.email_on_debate_comment?
end
def email_on_comment_reply?
@comment.reply? && @comment.parent.author.email_on_comment_reply?
end
def administrator_comment?
["1", true].include?(comment_params[:as_administrator]) && can?(:comment_as_administrator, Debate)
end