mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
notify: Do not wrap references
When sending notifications, do not wrap lines from the references section. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
eb3b0d537d
commit
6681e56551
1 changed files with 28 additions and 32 deletions
|
@ -26,8 +26,9 @@ sender = config.get('notifications', 'sender')
|
||||||
reply_to = config.get('notifications', 'reply-to')
|
reply_to = config.get('notifications', 'reply-to')
|
||||||
|
|
||||||
|
|
||||||
def send_notification(to, subject, body, cc=None, reference=None):
|
def send_notification(to, subject, body, refs, cc=None, reference=None):
|
||||||
body = str.join('\n', [textwrap.fill(line) for line in body.splitlines()])
|
body = '\n'.join([textwrap.fill(line) for line in body.splitlines()])
|
||||||
|
body += '\n\n' + refs
|
||||||
|
|
||||||
for recipient in to:
|
for recipient in to:
|
||||||
msg = email.mime.text.MIMEText(body, 'plain', 'utf-8')
|
msg = email.mime.text.MIMEText(body, 'plain', 'utf-8')
|
||||||
|
@ -91,10 +92,9 @@ def send_resetkey(cur, uid):
|
||||||
'associated with your email address. If you wish to reset your ' \
|
'associated with your email address. If you wish to reset your ' \
|
||||||
'password follow the link [1] below, otherwise ignore this ' \
|
'password follow the link [1] below, otherwise ignore this ' \
|
||||||
'message and nothing will happen.' % (username)
|
'message and nothing will happen.' % (username)
|
||||||
body += '\n\n'
|
refs = '[1] ' + aur_location + '/passreset/?resetkey=' + resetkey
|
||||||
body += '[1] ' + aur_location + '/passreset/?resetkey=' + resetkey
|
|
||||||
|
|
||||||
send_notification([to], subject, body)
|
send_notification([to], subject, body, refs)
|
||||||
|
|
||||||
def welcome(cur, uid):
|
def welcome(cur, uid):
|
||||||
cur.execute('SELECT UserName, Email, ResetKey FROM Users WHERE ID = %s',
|
cur.execute('SELECT UserName, Email, ResetKey FROM Users WHERE ID = %s',
|
||||||
|
@ -106,10 +106,9 @@ def welcome(cur, uid):
|
||||||
'password for your new account, please click the link [1] below. ' \
|
'password for your new account, please click the link [1] below. ' \
|
||||||
'If the link does not work, try copying and pasting it into your ' \
|
'If the link does not work, try copying and pasting it into your ' \
|
||||||
'browser.'
|
'browser.'
|
||||||
body += '\n\n'
|
body = '[1] ' + aur_location + '/passreset/?resetkey=' + resetkey
|
||||||
body += '[1] ' + aur_location + '/passreset/?resetkey=' + resetkey
|
|
||||||
|
|
||||||
send_notification([to], subject, body)
|
send_notification([to], subject, body, refs)
|
||||||
|
|
||||||
def comment(cur, uid, pkgbase_id):
|
def comment(cur, uid, pkgbase_id):
|
||||||
user = username_from_id(cur, uid)
|
user = username_from_id(cur, uid)
|
||||||
|
@ -128,12 +127,11 @@ def comment(cur, uid, pkgbase_id):
|
||||||
body += 'If you no longer wish to receive notifications about this ' \
|
body += 'If you no longer wish to receive notifications about this ' \
|
||||||
'package, please go to the package page [2] and select "%s".' % \
|
'package, please go to the package page [2] and select "%s".' % \
|
||||||
('Disable notifications')
|
('Disable notifications')
|
||||||
body += '\n\n'
|
refs = '[1] ' + user_uri + '\n'
|
||||||
body += '[1] ' + user_uri + '\n'
|
refs += '[2] ' + pkgbase_uri
|
||||||
body += '[2] ' + pkgbase_uri
|
|
||||||
thread_id = '<pkg-notifications-' + pkgbase + '@aur.archlinux.org>'
|
thread_id = '<pkg-notifications-' + pkgbase + '@aur.archlinux.org>'
|
||||||
|
|
||||||
send_notification(to, subject, body, reference=thread_id)
|
send_notification(to, subject, body, refs, reference=thread_id)
|
||||||
|
|
||||||
def flag(cur, uid, pkgbase_id):
|
def flag(cur, uid, pkgbase_id):
|
||||||
user = username_from_id(cur, uid)
|
user = username_from_id(cur, uid)
|
||||||
|
@ -170,19 +168,17 @@ def delete(cur, uid, old_pkgbase_id, new_pkgbase_id=None):
|
||||||
'If you no longer wish receive notifications about the new ' \
|
'If you no longer wish receive notifications about the new ' \
|
||||||
'package, please go to [3] and click "%s".' %\
|
'package, please go to [3] and click "%s".' %\
|
||||||
(user, old_pkgbase, new_pkgbase, 'Disable notifications')
|
(user, old_pkgbase, new_pkgbase, 'Disable notifications')
|
||||||
body += '\n\n'
|
refs = '[1] ' + user_uri + '\n'
|
||||||
body += '[1] ' + user_uri + '\n'
|
refs += '[2] ' + pkgbase_uri + '\n'
|
||||||
body += '[2] ' + pkgbase_uri + '\n'
|
refs += '[3] ' + new_pkgbase_uri
|
||||||
body += '[3] ' + new_pkgbase_uri
|
|
||||||
else:
|
else:
|
||||||
body = '%s [1] deleted %s [2].\n\n' \
|
body = '%s [1] deleted %s [2].\n\n' \
|
||||||
'You will no longer receive notifications about this ' \
|
'You will no longer receive notifications about this ' \
|
||||||
'package.' % (user, old_pkgbase)
|
'package.' % (user, old_pkgbase)
|
||||||
body += '\n\n'
|
refs = '[1] ' + user_uri + '\n'
|
||||||
body += '[1] ' + user_uri + '\n'
|
refs += '[2] ' + pkgbase_uri
|
||||||
body += '[2] ' + pkgbase_uri
|
|
||||||
|
|
||||||
send_notification(to, subject, body)
|
send_notification(to, subject, body, refs)
|
||||||
|
|
||||||
def request_open(cur, uid, reqid, reqtype, pkgbase_id, merge_into=None):
|
def request_open(cur, uid, reqid, reqtype, pkgbase_id, merge_into=None):
|
||||||
user = username_from_id(cur, uid)
|
user = username_from_id(cur, uid)
|
||||||
|
@ -200,19 +196,19 @@ def request_open(cur, uid, reqid, reqtype, pkgbase_id, merge_into=None):
|
||||||
merge_into_uri = aur_location + '/pkgbase/' + merge_into + '/'
|
merge_into_uri = aur_location + '/pkgbase/' + merge_into + '/'
|
||||||
body = '%s [1] filed a request to merge %s [2] into %s [3]:' % \
|
body = '%s [1] filed a request to merge %s [2] into %s [3]:' % \
|
||||||
(user, pkgbase, merge_into)
|
(user, pkgbase, merge_into)
|
||||||
body += '\n\n' + text + '\n\n'
|
body += '\n\n' + text
|
||||||
body += '[1] ' + user_uri + '\n'
|
refs = '[1] ' + user_uri + '\n'
|
||||||
body += '[2] ' + pkgbase_uri + '\n'
|
refs += '[2] ' + pkgbase_uri + '\n'
|
||||||
body += '[3] ' + merge_into_uri
|
refs += '[3] ' + merge_into_uri
|
||||||
else:
|
else:
|
||||||
body = '%s [1] filed a %s request for %s [2]:' % \
|
body = '%s [1] filed a %s request for %s [2]:' % \
|
||||||
(user, reqtype, pkgbase)
|
(user, reqtype, pkgbase)
|
||||||
body += '\n\n' + text + '\n\n'
|
body += '\n\n' + text
|
||||||
body += '[1] ' + user_uri + '\n'
|
refs = '[1] ' + user_uri + '\n'
|
||||||
body += '[2] ' + pkgbase_uri + '\n'
|
refs += '[2] ' + pkgbase_uri + '\n'
|
||||||
thread_id = '<pkg-request-' + reqid + '@aur.archlinux.org>'
|
thread_id = '<pkg-request-' + reqid + '@aur.archlinux.org>'
|
||||||
|
|
||||||
send_notification(to, subject, body, cc, thread_id)
|
send_notification(to, subject, body, refs, cc, thread_id)
|
||||||
|
|
||||||
def request_close(cur, uid, reqid, reason):
|
def request_close(cur, uid, reqid, reason):
|
||||||
user = username_from_id(cur, uid)
|
user = username_from_id(cur, uid)
|
||||||
|
@ -226,13 +222,13 @@ def request_close(cur, uid, reqid, reason):
|
||||||
subject = '[PRQ#%d] Request %s' % (int(reqid), reason.title())
|
subject = '[PRQ#%d] Request %s' % (int(reqid), reason.title())
|
||||||
body = 'Request #%d has been %s by %s [1]' % (int(reqid), reason, user)
|
body = 'Request #%d has been %s by %s [1]' % (int(reqid), reason, user)
|
||||||
if text.strip() == '':
|
if text.strip() == '':
|
||||||
body += '.\n\n'
|
body += '.'
|
||||||
else:
|
else:
|
||||||
body += ':\n\n' + text + '\n\n'
|
body += ':\n\n' + text
|
||||||
body += '[1] ' + user_uri
|
refs = '[1] ' + user_uri
|
||||||
thread_id = '<pkg-request-' + reqid + '@aur.archlinux.org>'
|
thread_id = '<pkg-request-' + reqid + '@aur.archlinux.org>'
|
||||||
|
|
||||||
send_notification(to, subject, body, cc, thread_id)
|
send_notification(to, subject, body, refs, cc, thread_id)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Reference in a new issue