[aur-dev] [PATCH 1/2] Remove duplicate recipients from Cc
When a user files a request for a package maintained by himself, he is currently included in the Cc list twice. Use array_unique() to omit repeated entries. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgreqfuncs.inc.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 8fba838..2ae64e0 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -173,6 +173,7 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { "[2] " . $AUR_LOCATION . get_pkgbase_uri($row['Name']) . "\n"; } $body = wordwrap($body, 70); + $cc = array_unique($cc); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8\r\n" . "Cc: " . implode(', ', $cc) . "\r\n"; @@ -281,6 +282,7 @@ function pkgreq_close($id, $reason, $comments, $auto_close=false) { $body .= "\n"; } $body = wordwrap($body, 70); + $cc = array_unique($cc); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8\r\n" . "Cc: " . implode(', ', $cc) . "\r\n"; -- 2.0.3
When auto-accepting a request, we need to close the package request before performing the actual action (disown/deletion/merge). Otherwise, the former maintainer is not included in the Cc list of the acceptance/rejection notification email. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgbasefuncs.inc.php | 28 ++++++++++++++++++++-------- web/lib/pkgreqfuncs.inc.php | 12 +++++++++--- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index cf0b09b..946209b 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -511,6 +511,16 @@ function pkgbase_delete ($base_ids, $merge_base_id, $via) { } } + /* + * Close package request if the deletion was initiated through the + * request interface. NOTE: This needs to happen *before* the actual + * deletion. Otherwise, the former maintainer will not be included in + * the Cc list of the request notification email. + */ + if ($via) { + pkgreq_close(intval($via), 'accepted', ''); + } + if ($merge_base_id) { /* Merge comments */ $q = "UPDATE PackageComments "; @@ -544,10 +554,6 @@ function pkgbase_delete ($base_ids, $merge_base_id, $via) { $q = "DELETE FROM PackageBases WHERE ID IN (" . implode(",", $base_ids) . ")"; $dbh->exec($q); - if ($via) { - pkgreq_close(intval($via), 'accepted', ''); - } - return array(true, __("The selected packages have been deleted.")); } @@ -579,6 +585,16 @@ function pkgbase_adopt ($base_ids, $action=true, $via) { } } + /* + * Close package request if the disownment was initiated through the + * request interface. NOTE: This needs to happen *before* the actual + * disown operation. Otherwise, the former maintainer will not be + * included in the Cc list of the request notification email. + */ + if ($via) { + pkgreq_close(intval($via), 'accepted', ''); + } + $dbh = DB::connect(); $q = "UPDATE PackageBases "; @@ -600,10 +616,6 @@ function pkgbase_adopt ($base_ids, $action=true, $via) { $dbh->exec($q); - if ($via) { - pkgreq_close(intval($via), 'accepted', ''); - } - if ($action) { pkgbase_notify(account_from_sid($_COOKIE["AURSID"]), $base_ids); return array(true, __("The selected packages have been adopted.")); diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 2ae64e0..5924959 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -189,13 +189,19 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { if ($type == 'orphan' && $details['OutOfDateTS'] > 0 && time() - $details['OutOfDateTS'] >= $AUTO_ORPHAN_AGE && $AUTO_ORPHAN_AGE > 0) { + /* + * Close package request. NOTE: This needs to happen *before* + * the actual disown operation. Otherwise, the former + * maintainer will not be included in the Cc list of the + * request notification email. + */ + pkgreq_close($request_id, "accepted", + "The package base has been flagged out-of-date " . + "since " . $out_of_date_time . ".", true); $q = "UPDATE PackageBases SET MaintainerUID = NULL "; $q.= "WHERE ID = " . $base_id; $dbh->exec($q); $out_of_date_time = gmdate("Y-m-d", intval($details["OutOfDateTS"])); - pkgreq_close($request_id, "accepted", - "The package base has been flagged out-of-date " . - "since " . $out_of_date_time . ".", true); } return array(true, __("Added request successfully.")); -- 2.0.3
participants (1)
-
Lukas Fleischer