Skip to content
Snippets Groups Projects
Commit 445a991e authored by Kevin Morris's avatar Kevin Morris Committed by Lukas Fleischer
Browse files

Exclude suspended Users from being notified

The existing notify.py script was grabbing entries regardless
of user suspension. This has been modified to only send notifications
to unsuspended users.

This change was written as a solution to
https://bugs.archlinux.org/task/65554

.

Signed-off-by: default avatarKevin Morris <kevr.gtalk@gmail.com>
Signed-off-by: default avatarLukas Fleischer <lfleischer@archlinux.org>
parent efe99dc1
No related branches found
No related tags found
No related merge requests found
......@@ -126,7 +126,7 @@ class ResetKeyNotification(Notification):
def __init__(self, conn, uid):
cur = conn.execute('SELECT UserName, Email, BackupEmail, ' +
'LangPreference, ResetKey ' +
'FROM Users WHERE ID = ?', [uid])
'FROM Users WHERE ID = ? AND Suspended = 0', [uid])
self._username, self._to, self._backup, self._lang, self._resetkey = cur.fetchone()
super().__init__()
......@@ -173,7 +173,8 @@ class CommentNotification(Notification):
'ON PackageNotifications.UserID = Users.ID WHERE ' +
'Users.CommentNotify = 1 AND ' +
'PackageNotifications.UserID != ? AND ' +
'PackageNotifications.PackageBaseID = ?',
'PackageNotifications.PackageBaseID = ? AND ' +
'Users.Suspended = 0',
[uid, pkgbase_id])
self._recipients = cur.fetchall()
cur = conn.execute('SELECT Comments FROM PackageComments WHERE ID = ?',
......@@ -220,7 +221,8 @@ class UpdateNotification(Notification):
'ON PackageNotifications.UserID = Users.ID WHERE ' +
'Users.UpdateNotify = 1 AND ' +
'PackageNotifications.UserID != ? AND ' +
'PackageNotifications.PackageBaseID = ?',
'PackageNotifications.PackageBaseID = ? AND ' +
'Users.Suspended = 0',
[uid, pkgbase_id])
self._recipients = cur.fetchall()
super().__init__()
......@@ -266,7 +268,8 @@ class FlagNotification(Notification):
'INNER JOIN PackageBases ' +
'ON PackageBases.MaintainerUID = Users.ID OR ' +
'PackageBases.ID = PackageComaintainers.PackageBaseID ' +
'WHERE PackageBases.ID = ?', [pkgbase_id])
'WHERE PackageBases.ID = ? AND ' +
'Users.Suspended = 0', [pkgbase_id])
self._recipients = cur.fetchall()
cur = conn.execute('SELECT FlaggerComment FROM PackageBases WHERE ' +
'ID = ?', [pkgbase_id])
......@@ -304,7 +307,8 @@ class OwnershipEventNotification(Notification):
'ON PackageNotifications.UserID = Users.ID WHERE ' +
'Users.OwnershipNotify = 1 AND ' +
'PackageNotifications.UserID != ? AND ' +
'PackageNotifications.PackageBaseID = ?',
'PackageNotifications.PackageBaseID = ? AND ' +
'Users.Suspended = 0',
[uid, pkgbase_id])
self._recipients = cur.fetchall()
cur = conn.execute('SELECT FlaggerComment FROM PackageBases WHERE ' +
......@@ -343,7 +347,7 @@ class ComaintainershipEventNotification(Notification):
def __init__(self, conn, uid, pkgbase_id):
self._pkgbase = pkgbase_from_id(conn, pkgbase_id)
cur = conn.execute('SELECT Email, LangPreference FROM Users ' +
'WHERE ID = ?', [uid])
'WHERE ID = ? AND Suspended = 0', [uid])
self._to, self._lang = cur.fetchone()
super().__init__()
......@@ -386,7 +390,8 @@ class DeleteNotification(Notification):
'INNER JOIN PackageNotifications ' +
'ON PackageNotifications.UserID = Users.ID WHERE ' +
'PackageNotifications.UserID != ? AND ' +
'PackageNotifications.PackageBaseID = ?',
'PackageNotifications.PackageBaseID = ? AND ' +
'Users.Suspended = 0',
[uid, old_pkgbase_id])
self._recipients = cur.fetchall()
super().__init__()
......@@ -433,7 +438,8 @@ class RequestOpenNotification(Notification):
'INNER JOIN Users ' +
'ON Users.ID = PackageRequests.UsersID ' +
'OR Users.ID = PackageBases.MaintainerUID ' +
'WHERE PackageRequests.ID = ?', [reqid])
'WHERE PackageRequests.ID = ? AND ' +
'Users.Suspended = 0', [reqid])
self._to = aurweb.config.get('options', 'aur_request_ml')
self._cc = [row[0] for row in cur.fetchall()]
cur = conn.execute('SELECT Comments FROM PackageRequests WHERE ID = ?',
......@@ -489,7 +495,8 @@ class RequestCloseNotification(Notification):
'INNER JOIN Users ' +
'ON Users.ID = PackageRequests.UsersID ' +
'OR Users.ID = PackageBases.MaintainerUID ' +
'WHERE PackageRequests.ID = ?', [reqid])
'WHERE PackageRequests.ID = ? AND ' +
'Users.Suspended = 0', [reqid])
self._to = aurweb.config.get('options', 'aur_request_ml')
self._cc = [row[0] for row in cur.fetchall()]
cur = conn.execute('SELECT PackageRequests.ClosureComment, ' +
......@@ -547,7 +554,8 @@ class TUVoteReminderNotification(Notification):
cur = conn.execute('SELECT Email, LangPreference FROM Users ' +
'WHERE AccountTypeID IN (2, 4) AND ID NOT IN ' +
'(SELECT UserID FROM TU_Votes ' +
'WHERE TU_Votes.VoteID = ?)', [vote_id])
'WHERE TU_Votes.VoteID = ?) AND ' +
'Users.Suspended = 0', [vote_id])
self._recipients = cur.fetchall()
super().__init__()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment