2021-01-29 00:49:27 +01:00
|
|
|
class UserMailer < ApplicationMailer
|
|
|
|
|
def notify_post_owner(comment:)
|
2024-03-09 17:26:24 +01:00
|
|
|
Current.tenant = comment.tenant
|
2021-01-29 00:49:27 +01:00
|
|
|
@comment = comment
|
|
|
|
|
@user = comment.post.user
|
|
|
|
|
|
2022-05-28 11:03:36 +02:00
|
|
|
mail(
|
|
|
|
|
to: @user.email,
|
2024-02-24 19:18:55 +01:00
|
|
|
subject: t('mailers.user.notify_post_owner.subject', site_name: site_name, post: comment.post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def notify_comment_owner(comment:)
|
2024-03-09 17:26:24 +01:00
|
|
|
Current.tenant = comment.tenant
|
2022-05-28 11:03:36 +02:00
|
|
|
@comment = comment
|
|
|
|
|
@user = comment.parent.user
|
|
|
|
|
|
|
|
|
|
mail(
|
|
|
|
|
to: @user.email,
|
2024-02-24 19:18:55 +01:00
|
|
|
subject: t('mailers.user.notify_comment_owner.subject', site_name: site_name, post: comment.post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
2024-03-09 17:26:24 +01:00
|
|
|
def notify_follower_of_post_update(comment:, follower:)
|
|
|
|
|
Current.tenant = comment.tenant
|
2022-05-28 11:03:36 +02:00
|
|
|
@comment = comment
|
2024-03-09 17:26:24 +01:00
|
|
|
@user = follower
|
2022-05-28 11:03:36 +02:00
|
|
|
|
|
|
|
|
mail(
|
2024-03-09 17:26:24 +01:00
|
|
|
to: follower.email,
|
|
|
|
|
subject: t('mailers.user.notify_follower_of_post_update.subject', site_name: site_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
|
|
|
|
2024-03-09 17:26:24 +01:00
|
|
|
def notify_follower_of_post_status_change(post:, follower:)
|
|
|
|
|
Current.tenant = post.tenant
|
2022-05-28 11:03:36 +02:00
|
|
|
@post = post
|
2024-03-09 17:26:24 +01:00
|
|
|
@user = follower
|
2022-05-28 11:03:36 +02:00
|
|
|
|
|
|
|
|
mail(
|
2024-03-09 17:26:24 +01:00
|
|
|
to: follower.email,
|
|
|
|
|
subject: t('mailers.user.notify_follower_of_post_status_change.subject', site_name: site_name, post: post.title)
|
2022-05-28 11:03:36 +02:00
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
2024-11-19 17:17:05 +01:00
|
|
|
def recap(frequency:, user:, published_posts_count:, pending_posts_count:)
|
|
|
|
|
Current.tenant = user.tenant
|
|
|
|
|
|
|
|
|
|
@frequency = frequency
|
|
|
|
|
@user = user
|
|
|
|
|
@published_posts_count = published_posts_count
|
|
|
|
|
@pending_posts_count = pending_posts_count
|
|
|
|
|
|
|
|
|
|
mail(
|
|
|
|
|
to: user.email,
|
|
|
|
|
subject: t('mailers.user.recap.subject', site_name: site_name, frequency: frequency)
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2022-05-28 11:03:36 +02:00
|
|
|
private
|
|
|
|
|
|
2024-02-24 19:18:55 +01:00
|
|
|
def site_name
|
2022-07-18 10:47:54 +02:00
|
|
|
Current.tenant_or_raise!.site_name
|
2022-05-28 11:03:36 +02:00
|
|
|
end
|
2021-01-29 00:49:27 +01:00
|
|
|
end
|