2021-01-29 00:49:27 +01:00
|
|
|
class UserMailer < ApplicationMailer
|
2022-06-05 11:40:43 +02:00
|
|
|
layout 'user_mailer'
|
|
|
|
|
|
2021-01-29 00:49:27 +01:00
|
|
|
def notify_post_owner(comment:)
|
|
|
|
|
@comment = comment
|
|
|
|
|
@user = comment.post.user
|
|
|
|
|
|
2022-05-28 11:03:36 +02:00
|
|
|
mail(
|
|
|
|
|
to: @user.email,
|
2022-06-05 11:40:43 +02:00
|
|
|
subject: default_i18n_subject(app_name: app_name, post: comment.post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def notify_comment_owner(comment:)
|
|
|
|
|
@comment = comment
|
|
|
|
|
@user = comment.parent.user
|
|
|
|
|
|
|
|
|
|
mail(
|
|
|
|
|
to: @user.email,
|
2022-06-05 11:40:43 +02:00
|
|
|
subject: default_i18n_subject(app_name: app_name, post: comment.post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def notify_followers_of_post_update(comment:)
|
|
|
|
|
@comment = comment
|
|
|
|
|
|
|
|
|
|
mail(
|
|
|
|
|
to: comment.post.followers.pluck(:email),
|
2022-06-05 11:40:43 +02:00
|
|
|
subject: default_i18n_subject(app_name: app_name, post: comment.post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
2021-01-29 00:49:27 +01:00
|
|
|
end
|
2022-05-28 11:03:36 +02:00
|
|
|
|
|
|
|
|
def notify_followers_of_post_status_change(post:)
|
|
|
|
|
@post = post
|
|
|
|
|
|
|
|
|
|
mail(
|
|
|
|
|
to: post.followers.pluck(:email),
|
2022-06-05 11:40:43 +02:00
|
|
|
subject: default_i18n_subject(app_name: app_name, post: post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def app_name
|
|
|
|
|
ENV.fetch('APP_NAME')
|
|
|
|
|
end
|
2021-01-29 00:49:27 +01:00
|
|
|
end
|