Verified Commit ccf11e57 authored by Frederik Schwan's avatar Frederik Schwan
Browse files

fix requests not being sent to the cc recipients

From a SMTP pov, the To and Cc header are not read. The real recipient
is stated at the begining of a send mail transaction.
It's up to the client to collect this recipient list. Sendmail does this
by reading the To and Cc header.
smtplib doesn't do this when being invoked with an explicit To array.
This commit adds the Cc people to the recipient array.
The issue has been introduced by the switch from sendmail to smtplib.
parent 613364b7
......@@ -78,7 +78,7 @@ class Notification:
msg['Subject'] = self.get_subject(lang)
msg['From'] = sender
msg['Reply-to'] = reply_to
msg['To'] = to
msg['To'] = self.get_to()
if self.get_cc():
msg['Cc'] = str.join(', ', self.get_cc())
msg['X-AUR-Reason'] = reason
......@@ -89,6 +89,10 @@ class Notification:
sendmail = aurweb.config.get('notifications', 'sendmail')
if sendmail:
# Since we iterate over self.get_recipients(), we overwrite
# the To header for sendmail to avoid sending the mail
# multiple times to the same recipient
msg['To'] = to
# send email using the sendmail binary specified in the
# configuration file
p = subprocess.Popen([sendmail, '-t', '-oi'],
......@@ -117,7 +121,6 @@ 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()
......@@ -136,6 +139,9 @@ class ResetKeyNotification(Notification):
else:
return [(self._to, self._lang)]
def get_to(self):
return self._to
def get_subject(self, lang):
return self._l10n.translate('AUR Password Reset', lang)
......@@ -184,6 +190,9 @@ class CommentNotification(Notification):
def get_recipients(self):
return self._recipients
def get_to(self):
return self._recipients
def get_subject(self, lang):
return self._l10n.translate('AUR Comment for {pkgbase}',
lang).format(pkgbase=self._pkgbase)
......@@ -228,6 +237,9 @@ class UpdateNotification(Notification):
def get_recipients(self):
return self._recipients
def get_to(self):
return self._recipients
def get_subject(self, lang):
return self._l10n.translate('AUR Package Update: {pkgbase}',
lang).format(pkgbase=self._pkgbase)
......@@ -276,6 +288,9 @@ class FlagNotification(Notification):
def get_recipients(self):
return self._recipients
def get_to(self):
return self._recipients
def get_subject(self, lang):
return self._l10n.translate('AUR Out-of-date Notification for '
'{pkgbase}',
......@@ -315,6 +330,9 @@ class OwnershipEventNotification(Notification):
def get_recipients(self):
return self._recipients
def get_to(self):
return self._recipients
def get_subject(self, lang):
return self._l10n.translate('AUR Ownership Notification for {pkgbase}',
lang).format(pkgbase=self._pkgbase)
......@@ -350,6 +368,9 @@ class ComaintainershipEventNotification(Notification):
def get_recipients(self):
return [(self._to, self._lang)]
def get_to(self):
return self._to
def get_subject(self, lang):
return self._l10n.translate('AUR Co-Maintainer Notification for '
'{pkgbase}',
......@@ -394,6 +415,9 @@ class DeleteNotification(Notification):
def get_recipients(self):
return self._recipients
def get_to(self):
return self._to
def get_subject(self, lang):
return self._l10n.translate('AUR Package deleted: {pkgbase}',
lang).format(pkgbase=self._old_pkgbase)
......@@ -435,7 +459,7 @@ class RequestOpenNotification(Notification):
'OR Users.ID = PackageBases.MaintainerUID ' +
'WHERE PackageRequests.ID = ?', [reqid])
self._to = aurweb.config.get('options', 'aur_request_ml')
self._cc = [row[0] for row in cur.fetchall()]
self._cc = [(row[0], 'en') for row in self._cc]
cur = conn.execute('SELECT Comments FROM PackageRequests WHERE ID = ?',
[reqid])
self._text = cur.fetchone()[0]
......@@ -444,10 +468,13 @@ class RequestOpenNotification(Notification):
self._merge_into = merge_into
def get_recipients(self):
return [(self._to, 'en')]
return [(self._to, 'en'), self._cc]
def get_to(self):
return self._to
def get_cc(self):
return self._cc
return [row[0] for row in self._cc]
def get_subject(self, lang):
return '[PRQ#%d] %s Request for %s' % \
......@@ -491,7 +518,7 @@ class RequestCloseNotification(Notification):
'OR Users.ID = PackageBases.MaintainerUID ' +
'WHERE PackageRequests.ID = ?', [reqid])
self._to = aurweb.config.get('options', 'aur_request_ml')
self._cc = [row[0] for row in cur.fetchall()]
self._cc = [(row[0], 'en') for row in self._cc]
cur = conn.execute('SELECT PackageRequests.ClosureComment, ' +
'RequestTypes.Name, ' +
'PackageRequests.PackageBaseName ' +
......@@ -504,10 +531,13 @@ class RequestCloseNotification(Notification):
self._reason = reason
def get_recipients(self):
return [(self._to, 'en')]
return [(self._to, 'en'), self._cc]
def get_to(self):
return self._to
def get_cc(self):
return self._cc
return [row[0] for row in self._cc]
def get_subject(self, lang):
return '[PRQ#%d] %s Request for %s %s' % (self._reqid,
......@@ -554,6 +584,9 @@ class TUVoteReminderNotification(Notification):
def get_recipients(self):
return self._recipients
def get_to(self):
return self._recipients
def get_subject(self, lang):
return self._l10n.translate('TU Vote Reminder: Proposal {id}',
lang).format(id=self._vote_id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment