-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathadmin_mailer.rb
112 lines (103 loc) · 3.58 KB
/
admin_mailer.rb
1
2
3
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
class AdminMailer < ActionMailer::Base
helper :application
include ApplicationHelper
default from: "notifications@#{ActionMailer::Base.default_url_options[:host]}"
def notify_node_moderators(node)
subject = '[New Public Lab poster needs moderation] ' + node.title
@node = node
@user = node.author
@footer = feature('email-footer')
moderators = User.where(role: %w(moderator admin)).collect(&:email)
mail(
to: "moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)
end
def notify_comment_moderators(comment)
subject = '[New Public Lab poster needs moderation]'
@comment = comment
@user = comment.author
@footer = feature('email-footer')
moderators = User.where(role: %w(moderator admin)).collect(&:email)
mail(
to: "comment-moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)
end
def notify_author_of_approval(node, moderator)
subject = '[Public Lab] Your post was approved!'
@author = node.author
@moderator = moderator
@node = node
@footer = feature('email-footer')
mail(to: @author.email, subject: subject)
end
def notify_author_of_comment_approval(comment, moderator)
subject = '[Public Lab] Your comment was approved!'
@author_mail = comment.author.email
@moderator = moderator
@comment = comment
@footer = feature('email-footer')
mail(to: @author_mail, subject: subject)
end
# Will this further bait spammers? If we don't,
# will non-spammers whose posts were moderated get confused?
# Should: show explanation/appeal process to authors who visit again
# Should: prompt moderators to reach out if it's not spam, but a guidelines violation
# def notify_author_of_spam(node)
# end
def notify_moderators_of_comment_spam(comment, moderator)
subject = '[New Public Lab comment needs moderation]'
@author = comment.author
@moderator = moderator
@comment = comment
@footer = feature('email-footer')
moderators = User.where(role: %w(moderator admin)).collect(&:email)
mail(
to: "comment-moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)
end
def notify_moderators_of_approval(node, moderator)
subject = '[New Public Lab poster needs moderation] ' + node.title
@author = node.author
@moderator = moderator
@node = node
@footer = feature('email-footer')
moderators = User.where(role: %w(moderator admin)).collect(&:email)
mail(
to: "moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)
end
def notify_moderators_of_comment_approval(comment, moderator)
subject = '[New Public Lab commenter needs moderation]'
@author = comment.author
@moderator = moderator
@comment = comment
@footer = feature('email-footer')
moderators = User.where(role: %w(moderator admin)).collect(&:email)
mail(
to: "comment-moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)
end
def notify_moderators_of_spam(node, moderator)
subject = '[New Public Lab poster needs moderation] ' + node.title
@author = node.author
@moderator = moderator
@node = node
@footer = feature('email-footer')
moderators = User.where(role: %w(moderator admin)).collect(&:email)
mail(
to: "moderators@#{ActionMailer::Base.default_url_options[:host]}",
bcc: moderators,
subject: subject
)
end
end