Files
astuto/app/mailers/user_mailer.rb
Riccardo Graziosi 78049a820c Add internationalization (#114)
🇬🇧 and 🇮🇹
2022-06-05 11:40:43 +02:00

47 lines
997 B
Ruby

class UserMailer < ApplicationMailer
layout 'user_mailer'
def notify_post_owner(comment:)
@comment = comment
@user = comment.post.user
mail(
to: @user.email,
subject: default_i18n_subject(app_name: app_name, post: comment.post.title)
)
end
def notify_comment_owner(comment:)
@comment = comment
@user = comment.parent.user
mail(
to: @user.email,
subject: default_i18n_subject(app_name: app_name, post: comment.post.title)
)
end
def notify_followers_of_post_update(comment:)
@comment = comment
mail(
to: comment.post.followers.pluck(:email),
subject: default_i18n_subject(app_name: app_name, post: comment.post.title)
)
end
def notify_followers_of_post_status_change(post:)
@post = post
mail(
to: post.followers.pluck(:email),
subject: default_i18n_subject(app_name: app_name, post: post.title)
)
end
private
def app_name
ENV.fetch('APP_NAME')
end
end