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
|
# ===GLSAMaker v2
# Copyright (C) 2010-11 Alex Legler <a3li@gentoo.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# For more information, see the LICENSE file.
module Glsamaker
module Mail
module_function
def edit_notification(glsa, diff, user)
if GLSAMAKER_NO_EMAIL
Rails.logger.info "Not sending email."
return false
end
if glsa.restricted
Rails.logger.info "Not sending email, confidential item."
return false
end
User.find(:all, :conditions => 'id > 0').each do |rcpt|
next unless rcpt.can_access? glsa
unless rcpt.get_pref_category(:mail)[:edit] == false
GlsaMailer.edit(rcpt, glsa, diff, user).deliver
end
end
end
def request_notification(glsa, user)
if GLSAMAKER_NO_EMAIL
Rails.logger.info "Not sending email."
return false
end
if glsa.restricted
Rails.logger.info "Not sending email, confidential item."
return false
end
User.find(:all, :conditions => 'id > 0').each do |rcpt|
next unless rcpt.can_access? glsa
unless rcpt.get_pref_category(:mail)[:request] == false
GlsaMailer.new_request(rcpt, glsa, user).deliver
end
end
end
def comment_notification(glsa, comment, user)
if GLSAMAKER_NO_EMAIL
Rails.logger.info "Not sending email."
return false
end
# Nothing to do if there's no submitter yet
return if glsa.status == 'request'
if glsa.restricted
Rails.logger.info "Not sending email, confidential item."
return false
end
rcpt = glsa.submitter
return unless rcpt.can_access? glsa
return if rcpt == user
unless rcpt.get_pref_category(:mail)[:comment] == false
GlsaMailer.comment(rcpt, glsa, comment, user).deliver
end
end
def approval_notification(glsa)
if GLSAMAKER_NO_EMAIL
Rails.logger.info "Not sending email."
return false
end
if glsa.restricted
Rails.logger.info "Not sending email, confidential item."
return false
end
rcpt = glsa.submitter
return unless rcpt.can_access? glsa
unless rcpt.get_pref_category(:mail)[:comment] == false
GlsaMailer.approval(rcpt, glsa).deliver
end
end
def send_text(text, subject, user, footer = true)
if GLSAMAKER_NO_EMAIL
Rails.logger.info "Not sending email."
return false
end
GlsaMailer.text(user, subject, text, footer).deliver
end
end
end
|