summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-11-10 19:49:13 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2016-02-07 10:52:05 +0100
commitaa5e58db81b8a243e03d0f08925c2d1f34c82304 (patch)
tree22b086afdf5dc6173f5964342be0f09f3d266571 /scripts
parent3412de21d32708b44d1fb3011649734e3cc67d9b (diff)
downloadaurweb-aa5e58db81b8a243e03d0f08925c2d1f34c82304.tar.xz
Add global comment notification setting
Add a configuration option to the account edit page that allows for globally enabling/disabling package base comment notifications. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/notify.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/notify.py b/scripts/notify.py
index 08cdda8..6b10600 100755
--- a/scripts/notify.py
+++ b/scripts/notify.py
@@ -95,6 +95,16 @@ def get_recipients(cur, pkgbase_id, uid):
return [row[0] for row in cur.fetchall()]
+def get_comment_recipients(cur, pkgbase_id, uid):
+ cur.execute('SELECT DISTINCT Users.Email FROM Users ' +
+ 'INNER JOIN PackageNotifications ' +
+ 'ON PackageNotifications.UserID = Users.ID WHERE ' +
+ 'Users.CommentNotify = 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 ' +
@@ -159,7 +169,7 @@ def welcome(cur, uid):
def comment(cur, uid, pkgbase_id, comment_id):
user = username_from_id(cur, uid)
pkgbase = pkgbase_from_id(cur, pkgbase_id)
- to = get_recipients(cur, pkgbase_id, uid)
+ to = get_comment_recipients(cur, pkgbase_id, uid)
text = get_comment(cur, comment_id)
user_uri = aur_location + '/account/' + user + '/'