diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2015-11-10 20:18:13 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-02-07 10:54:20 +0100 |
commit | 64072461dfcc74857087b23c9ba7d9812b6afe40 (patch) | |
tree | 753980782ed91c694fe583495627a5dc8b8b7f4b /scripts | |
parent | aa5e58db81b8a243e03d0f08925c2d1f34c82304 (diff) | |
download | aurweb-64072461dfcc74857087b23c9ba7d9812b6afe40.tar.xz |
Add support for package update notifications
Introduce a new notification option to receive notifications when a new
commit is pushed to a package repository.
Implements FS#30109.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/notify.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/scripts/notify.py b/scripts/notify.py index 6b10600..56534ae 100755 --- a/scripts/notify.py +++ b/scripts/notify.py @@ -105,6 +105,16 @@ def get_comment_recipients(cur, pkgbase_id, uid): return [row[0] for row in cur.fetchall()] +def get_update_recipients(cur, pkgbase_id, uid): + cur.execute('SELECT DISTINCT Users.Email FROM Users ' + + 'INNER JOIN PackageNotifications ' + + 'ON PackageNotifications.UserID = Users.ID WHERE ' + + 'Users.UpdateNotify = 1 AND ' + + 'PackageNotifications.UserID != %s AND ' + + 'PackageNotifications.PackageBaseID = %s', [uid, pkgbase_id]) + return [row[0] for row in cur.fetchall()] + + def get_request_recipients(cur, pkgbase_id, uid): cur.execute('SELECT DISTINCT Users.Email FROM Users ' + 'INNER JOIN PackageBases ' + @@ -189,6 +199,28 @@ def comment(cur, uid, pkgbase_id, comment_id): send_notification(to, subject, body, refs, headers) +def update(cur, uid, pkgbase_id): + user = username_from_id(cur, uid) + pkgbase = pkgbase_from_id(cur, pkgbase_id) + to = get_update_recipients(cur, pkgbase_id, uid) + + user_uri = aur_location + '/account/' + user + '/' + pkgbase_uri = aur_location + '/pkgbase/' + pkgbase + '/' + + subject = 'AUR Package Update: %s' % (pkgbase) + body = '%s [1] pushed a new commit to %s [2].' % (user, pkgbase) + body += '\n\n' + body += 'If you no longer wish to receive notifications about this ' \ + 'package, please go to the package page [2] and select "%s".' % \ + ('Disable notifications') + refs = '[1] ' + user_uri + '\n' + refs += '[2] ' + pkgbase_uri + thread_id = '<pkg-notifications-' + pkgbase + '@aur.archlinux.org>' + headers = headers_reply(thread_id) + + send_notification(to, subject, body, refs, headers) + + def flag(cur, uid, pkgbase_id): user = username_from_id(cur, uid) pkgbase = pkgbase_from_id(cur, pkgbase_id) @@ -327,6 +359,7 @@ if __name__ == '__main__': 'send-resetkey': send_resetkey, 'welcome': welcome, 'comment': comment, + 'update': update, 'flag': flag, 'comaintainer-add': comaintainer_add, 'comaintainer-remove': comaintainer_remove, |