Class: Workarea::Admin::CommentMailer

Inherits:
ApplicationMailer
  • Object
show all
Defined in:
app/mailers/workarea/admin/comment_mailer.rb

Instance Method Summary collapse

Instance Method Details

#notify(user_id, comment_id) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/mailers/workarea/admin/comment_mailer.rb', line 4

def notify(user_id, comment_id)
  @user = User.find(user_id) rescue nil
  return false unless @user&.email.present?

  model = Comment.where(id: comment_id).first
  return false unless model.present?

  return false if model.author_id == user_id

  @comment = CommentViewModel.new(model)
  @commentable = model.commentable
  @comments = CommentViewModel.wrap(
    @commentable.comments.except(comment_id).to_a
  )

  set_colors

  mail(
    to: @user.email,
    from: Workarea.config.email_from,
    subject: t(
      'workarea.admin.comment_mailer.notify.subject',
      commentable: @commentable.name
    )
  )
end