summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xaurweb/scripts/notify.py18
-rwxr-xr-xtest/t2500-notify.t16
2 files changed, 25 insertions, 9 deletions
diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py
index 899f8acc..9d4f3bde 100755
--- a/aurweb/scripts/notify.py
+++ b/aurweb/scripts/notify.py
@@ -14,10 +14,6 @@ import aurweb.l10n
aur_location = aurweb.config.get('options', 'aur_location')
-def headers_cc(cclist):
- return {'Cc': str.join(', ', cclist)}
-
-
def headers_msgid(thread_id):
return {'Message-ID': thread_id}
@@ -53,6 +49,9 @@ class Notification:
def get_headers(self):
return {}
+ def get_cc(self):
+ return []
+
def get_body_fmt(self, lang):
body = ''
for line in self.get_body(lang).splitlines():
@@ -80,6 +79,8 @@ class Notification:
msg['From'] = sender
msg['Reply-to'] = reply_to
msg['To'] = to
+ if self.get_cc():
+ msg['Cc'] = str.join(', ', self.get_cc())
msg['X-AUR-Reason'] = reason
msg['Date'] = email.utils.formatdate(localtime=True)
@@ -116,6 +117,7 @@ class Notification:
server.login(user, passwd)
server.set_debuglevel(0)
+ deliver_to = [to] + self.get_cc()
server.sendmail(sender, to, msg.as_bytes())
server.quit()
@@ -444,6 +446,9 @@ class RequestOpenNotification(Notification):
def get_recipients(self):
return [(self._to, 'en')]
+ def get_cc(self):
+ return self._cc
+
def get_subject(self, lang):
return '[PRQ#%d] %s Request for %s' % \
(self._reqid, self._reqtype.title(), self._pkgbase)
@@ -472,7 +477,6 @@ class RequestOpenNotification(Notification):
# Use a deterministic Message-ID for the first email referencing a
# request.
headers = headers_msgid(thread_id)
- headers.update(headers_cc(self._cc))
return headers
@@ -502,6 +506,9 @@ class RequestCloseNotification(Notification):
def get_recipients(self):
return [(self._to, 'en')]
+ def get_cc(self):
+ return self._cc
+
def get_subject(self, lang):
return '[PRQ#%d] %s Request for %s %s' % (self._reqid,
self._reqtype.title(),
@@ -531,7 +538,6 @@ class RequestCloseNotification(Notification):
def get_headers(self):
thread_id = '<pkg-request-' + str(self._reqid) + '@aur.archlinux.org>'
headers = headers_reply(thread_id)
- headers.update(headers_cc(self._cc))
return headers
diff --git a/test/t2500-notify.t b/test/t2500-notify.t
index 5ef64c18..713b31e3 100755
--- a/test/t2500-notify.t
+++ b/test/t2500-notify.t
@@ -277,13 +277,18 @@ test_expect_success 'Test subject and body of merge notifications.' '
test_cmp actual expected
'
-test_expect_success 'Test subject and body of request open notifications.' '
+test_expect_success 'Test Cc, subject and body of request open notifications.' '
cat <<-EOD | sqlite3 aur.db &&
/* Use package request IDs which can be distinguished from other IDs. */
- INSERT INTO PackageRequests (ID, PackageBaseID, PackageBaseName, UsersID, ReqTypeID, Comments, ClosureComment) VALUES (3001, 1001, "foobar", 1, 1, "This is a request test comment.", "");
+ INSERT INTO PackageRequests (ID, PackageBaseID, PackageBaseName, UsersID, ReqTypeID, Comments, ClosureComment) VALUES (3001, 1001, "foobar", 2, 1, "This is a request test comment.", "");
EOD
>sendmail.out &&
"$NOTIFY" request-open 1 3001 orphan 1001 &&
+ grep ^Cc: sendmail.out >actual &&
+ cat <<-EOD >expected &&
+ Cc: user@localhost, tu@localhost
+ EOD
+ test_cmp actual expected &&
grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected &&
Subject: [PRQ#3001] Orphan Request for foobar
@@ -324,9 +329,14 @@ test_expect_success 'Test subject and body of request open notifications for mer
test_cmp actual expected
'
-test_expect_success 'Test subject and body of request close notifications.' '
+test_expect_success 'Test Cc, subject and body of request close notifications.' '
>sendmail.out &&
"$NOTIFY" request-close 1 3001 accepted &&
+ grep ^Cc: sendmail.out >actual &&
+ cat <<-EOD >expected &&
+ Cc: user@localhost, tu@localhost
+ EOD
+ test_cmp actual expected &&
grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected &&
Subject: [PRQ#3001] Deletion Request for foobar Accepted