[aur-dev] [PATCH 1/2] Send out-of-date notifications to co-maintainers
Currently, only package maintainers receive out-of-date notifications for their packages. Add package base co-maintainers to the list of recipients for out-of-date notifications. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- aurweb/scripts/notify.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/aurweb/scripts/notify.py b/aurweb/scripts/notify.py index ddd6e49..8fdfeb9 100755 --- a/aurweb/scripts/notify.py +++ b/aurweb/scripts/notify.py @@ -73,12 +73,15 @@ def get_user_email(conn, uid): return cur.fetchone()[0] -def get_maintainer_email(conn, pkgbase_id): - cur = conn.execute('SELECT Users.Email FROM Users ' + +def get_flag_recipients(conn, pkgbase_id): + cur = conn.execute('SELECT DISTINCT Users.Email FROM Users ' + + 'LEFT JOIN PackageComaintainers ' + + 'ON PackageComaintainers.UsersID = Users.ID ' + 'INNER JOIN PackageBases ' + - 'ON PackageBases.MaintainerUID = Users.ID WHERE ' + - 'PackageBases.ID = ?', [pkgbase_id]) - return cur.fetchone()[0] + 'ON PackageBases.MaintainerUID = Users.ID OR ' + + 'PackageBases.ID = PackageComaintainers.PackageBaseID ' + + 'WHERE PackageBases.ID = ?', [pkgbase_id]) + return [row[0] for row in cur.fetchall()] def get_recipients(conn, pkgbase_id, uid): @@ -247,7 +250,7 @@ def update(conn, uid, pkgbase_id): def flag(conn, uid, pkgbase_id): user = username_from_id(conn, uid) pkgbase = pkgbase_from_id(conn, pkgbase_id) - to = [get_maintainer_email(conn, pkgbase_id)] + to = get_flag_recipients(conn, pkgbase_id) text = get_flagger_comment(conn, pkgbase_id) user_uri = aur_location + '/account/' + user + '/' -- 2.10.2
Make sure that out-of-date notifications are sent to package base maintainers as well as co-maintainers. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- test/t2500-notify.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 test/t2500-notify.sh diff --git a/test/t2500-notify.sh b/test/t2500-notify.sh new file mode 100755 index 0000000..1b20945 --- /dev/null +++ b/test/t2500-notify.sh @@ -0,0 +1,33 @@ +#!/bin/sh + +test_description='notify tests' + +. ./setup.sh + +test_expect_success 'Test out-of-date notifications.' ' + cat <<-EOD | sqlite3 aur.db && + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (1, "foobar", 1, 0, 0); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (2, "foobar2", 2, 0, 0); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (3, "foobar3", NULL, 0, 0); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (4, "foobar4", 1, 0, 0); + INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1, 2, 1); + INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1, 4, 2); + INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (2, 3, 1); + INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (2, 5, 2); + INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (3, 4, 1); + EOD + >sendmail.out && + "$NOTIFY" flag 1 1 && + cat <<-EOD >expected && + Subject: AUR Out-of-date Notification for foobar + To: tu@localhost + Subject: AUR Out-of-date Notification for foobar + To: user2@localhost + Subject: AUR Out-of-date Notification for foobar + To: user@localhost + EOD + grep "^\(Subject\|To\)" sendmail.out >sendmail.parts && + test_cmp sendmail.parts expected +' + +test_done -- 2.10.2
participants (1)
-
Lukas Fleischer