mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 03:07:52 +01:00
Post follow and updates notifications V1 (#111)
* It is now possible to follow a post in order to receive updates about it * Notifications are now sent when updates are published * Post status changes are now tracked * Update sidebar now shows the post status history * Mark a comment as a post update using the comment form * ... more ...
This commit is contained in:
committed by
GitHub
parent
ce7be1b30c
commit
dad382d2b1
@@ -1,10 +1,45 @@
|
||||
class UserMailer < ApplicationMailer
|
||||
default from: "notifications@example.com"
|
||||
|
||||
def notify_post_owner(comment:)
|
||||
@comment = comment
|
||||
@user = comment.post.user
|
||||
|
||||
mail(to: @user.email, subject: "[#{ENV.fetch('APP_NAME')}] - New comment on #{comment.post.title}")
|
||||
mail(
|
||||
to: @user.email,
|
||||
subject: "[#{app_name}] New comment on #{comment.post.title}"
|
||||
)
|
||||
end
|
||||
|
||||
def notify_comment_owner(comment:)
|
||||
@comment = comment
|
||||
@user = comment.parent.user
|
||||
|
||||
mail(
|
||||
to: @user.email,
|
||||
subject: "[#{app_name}] New reply on your comment from #{comment.post.title}"
|
||||
)
|
||||
end
|
||||
|
||||
def notify_followers_of_post_update(comment:)
|
||||
@comment = comment
|
||||
|
||||
mail(
|
||||
to: comment.post.followers.pluck(:email),
|
||||
subject: "[#{app_name}] New update on #{comment.post.title}"
|
||||
)
|
||||
end
|
||||
|
||||
def notify_followers_of_post_status_change(post:)
|
||||
@post = post
|
||||
|
||||
mail(
|
||||
to: post.followers.pluck(:email),
|
||||
subject: "[#{app_name}] Status change on post #{post.title}"
|
||||
)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def app_name
|
||||
ENV.fetch('APP_NAME')
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user