Remove PackageNotifications when User is suspended

Message ID 20200703190211.11979-1-kevr.gtalk@gmail.com
State New
Headers show
Series Remove PackageNotifications when User is suspended | expand

Commit Message

Kevin Morris July 3, 2020, 7:02 p.m. UTC
This path will only trigger when suspending a user through an
account page; if the database is managed manually or through
another script, PackageNotifications will also need manual
modifications if intended.

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

Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
---
 web/lib/acctfuncs.inc.php | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kevin Morris July 4, 2020, 12:06 a.m. UTC | #1
Updated patch inc which only modifies `scripts/notify.py` and preserves
notification records.

On Fri, Jul 3, 2020 at 12:02 PM Kevin Morris <kevr.gtalk@gmail.com> wrote:

> This path will only trigger when suspending a user through an
> account page; if the database is managed manually or through
> another script, PackageNotifications will also need manual
> modifications if intended.
>
> This change was written as a solution to
> https://bugs.archlinux.org/task/65554.
>
> Signed-off-by: Kevin Morris <kevr.gtalk@gmail.com>
> ---
>  web/lib/acctfuncs.inc.php | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
> index d238c0e0..fb7cca8c 100644
> --- a/web/lib/acctfuncs.inc.php
> +++ b/web/lib/acctfuncs.inc.php
> @@ -403,6 +403,10 @@ function
> process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$BE="",$H="",$P="
>                 $q.= " WHERE ID = ".intval($UID);
>                 $result = $dbh->exec($q);
>
> +               // Clean up PackageNotifications for $UID as well.
> +               $q = "DELETE FROM PackageNotifications WHERE UserID =
> ".intval($UID);
> +               $result = $dbh->exec($q);
> +
>                 if (isset($ssh_keys) && count($ssh_keys) > 0) {
>                         $ssh_key_result = account_set_ssh_keys($UID,
> $ssh_keys, $ssh_fingerprints);
>                 } else {
> --
> 2.20.1
>
>

Patch

diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index d238c0e0..fb7cca8c 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -403,6 +403,10 @@  function process_account_form($TYPE,$A,$U="",$T="",$S="",$E="",$BE="",$H="",$P="
 		$q.= " WHERE ID = ".intval($UID);
 		$result = $dbh->exec($q);
 
+		// Clean up PackageNotifications for $UID as well.
+		$q = "DELETE FROM PackageNotifications WHERE UserID = ".intval($UID);
+		$result = $dbh->exec($q);
+
 		if (isset($ssh_keys) && count($ssh_keys) > 0) {
 			$ssh_key_result = account_set_ssh_keys($UID, $ssh_keys, $ssh_fingerprints);
 		} else {