[aur-dev] [PATCH 1/3] Bcc notification emails to the request creator
Add both the request creator and the current package maintainer to the Bcc list of notification emails for package requests. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgreqfuncs.inc.php | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 09047eb..61d619b 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -57,6 +57,23 @@ function pkgreq_get_pkgbase_name($id) { } /** + * Obtain the email address of the creator of a package request + * + * @param int $id Package request ID to retrieve the creator for + * + * @return int The email address of the creator + */ +function pkgreq_get_creator_email($id) { + $dbh = DB::connect(); + + $q = "SELECT Email FROM Users INNER JOIN PackageRequests "; + $q.= "ON Users.ID = PackageRequests.UsersID "; + $q.= "WHERE PackageRequests.ID = " . intval($id); + $result = $dbh->query($q); + return $result->fetch(PDO::FETCH_COLUMN, 0); +} + +/** * File a deletion/orphan request against a package base * * @global string $AUR_LOCATION The AUR's URL used for notification e-mails @@ -108,15 +125,15 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { * Send e-mail notifications. * TODO: Move notification logic to separate function where it belongs. */ + $bcc = array(pkgreq_get_creator_email($request_id)); + $q = "SELECT Users.Email "; $q.= "FROM Users INNER JOIN PackageBases "; $q.= "ON PackageBases.MaintainerUID = Users.ID "; $q.= "WHERE PackageBases.ID = " . intval($base_id); $result = $dbh->query($q); if ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $bcc = $row['Email']; - } else { - unset($bcc); + $bcc[] = $row['Email']; } $q = "SELECT Name FROM PackageBases WHERE ID = "; @@ -138,10 +155,8 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { "[2] " . $AUR_LOCATION . get_pkgbase_uri($row['Name']) . "\n"; $body = wordwrap($body, 70); $headers = "MIME-Version: 1.0\r\n" . - "Content-type: text/plain; charset=UTF-8\r\n"; - if (!empty($bcc)) { - $headers .= "Bcc: $bcc\r\n"; - } + "Content-type: text/plain; charset=UTF-8\r\n" . + "Bcc: " . implode(', ', $bcc) . "\r\n"; $thread_id = "<pkg-request-" . $request_id . "@aur.archlinux.org>"; $headers .= "From: notify@aur.archlinux.org\r\n" . "Message-ID: $thread_id\r\n" . @@ -194,6 +209,8 @@ function pkgreq_close($id, $reason, $comments) { * Send e-mail notifications. * TODO: Move notification logic to separate function where it belongs. */ + $bcc = array(pkgreq_get_creator_email($id)); + $q = "SELECT Users.Email "; $q.= "FROM Users INNER JOIN PackageBases "; $q.= "ON PackageBases.MaintainerUID = Users.ID "; @@ -202,9 +219,7 @@ function pkgreq_close($id, $reason, $comments) { $q.= "WHERE PackageRequests.ID = " . $id; $result = $dbh->query($q); if ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $bcc = $row['Email']; - } else { - unset($bcc); + $bcc[] = $row['Email']; } /* @@ -224,10 +239,8 @@ function pkgreq_close($id, $reason, $comments) { $body .= "[1] " . $AUR_LOCATION . get_user_uri($username) . "\n"; $body = wordwrap($body, 70); $headers = "MIME-Version: 1.0\r\n" . - "Content-type: text/plain; charset=UTF-8\r\n"; - if (!empty($bcc)) { - $headers .= "Bcc: $bcc\r\n"; - } + "Content-type: text/plain; charset=UTF-8\r\n" . + "Bcc: " . implode(', ', $bcc) . "\r\n"; $thread_id = "<pkg-request-" . $id . "@aur.archlinux.org>"; $headers .= "From: notify@aur.archlinux.org\r\n" . "In-Reply-To: $thread_id\r\n" . -- 2.0.1
Add the request creator and the current package maintainer to Cc instead of Bcc when sending notification emails for package requests. This allows users to forward any discussion to both of them by using the "Group Reply" function of their MUA. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgreqfuncs.inc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 61d619b..005825f 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -125,7 +125,7 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { * Send e-mail notifications. * TODO: Move notification logic to separate function where it belongs. */ - $bcc = array(pkgreq_get_creator_email($request_id)); + $cc = array(pkgreq_get_creator_email($request_id)); $q = "SELECT Users.Email "; $q.= "FROM Users INNER JOIN PackageBases "; @@ -133,7 +133,7 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { $q.= "WHERE PackageBases.ID = " . intval($base_id); $result = $dbh->query($q); if ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $bcc[] = $row['Email']; + $cc[] = $row['Email']; } $q = "SELECT Name FROM PackageBases WHERE ID = "; @@ -156,7 +156,7 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { $body = wordwrap($body, 70); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8\r\n" . - "Bcc: " . implode(', ', $bcc) . "\r\n"; + "Cc: " . implode(', ', $cc) . "\r\n"; $thread_id = "<pkg-request-" . $request_id . "@aur.archlinux.org>"; $headers .= "From: notify@aur.archlinux.org\r\n" . "Message-ID: $thread_id\r\n" . @@ -209,7 +209,7 @@ function pkgreq_close($id, $reason, $comments) { * Send e-mail notifications. * TODO: Move notification logic to separate function where it belongs. */ - $bcc = array(pkgreq_get_creator_email($id)); + $cc = array(pkgreq_get_creator_email($id)); $q = "SELECT Users.Email "; $q.= "FROM Users INNER JOIN PackageBases "; @@ -219,7 +219,7 @@ function pkgreq_close($id, $reason, $comments) { $q.= "WHERE PackageRequests.ID = " . $id; $result = $dbh->query($q); if ($row = $result->fetch(PDO::FETCH_ASSOC)) { - $bcc[] = $row['Email']; + $cc[] = $row['Email']; } /* @@ -240,7 +240,7 @@ function pkgreq_close($id, $reason, $comments) { $body = wordwrap($body, 70); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8\r\n" . - "Bcc: " . implode(', ', $bcc) . "\r\n"; + "Cc: " . implode(', ', $cc) . "\r\n"; $thread_id = "<pkg-request-" . $id . "@aur.archlinux.org>"; $headers .= "From: notify@aur.archlinux.org\r\n" . "In-Reply-To: $thread_id\r\n" . -- 2.0.1
When sending the initial notification email for a merge request, include the name of the package base that is the target of the requested merge operation. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de> --- web/lib/pkgreqfuncs.inc.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 005825f..fcab648 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -148,11 +148,21 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { * user who posted the comment was in. */ $username = username_from_sid($_COOKIE['AURSID']); - $body = - $username . " [1] filed a " . $type . " request for " . - $row['Name'] . " [2]:\n\n" . $comments . "\n\n" . - "[1] " . $AUR_LOCATION . get_user_uri($username) . "\n" . - "[2] " . $AUR_LOCATION . get_pkgbase_uri($row['Name']) . "\n"; + if ($type == 'merge') { + $body = + $username . " [1] filed a request to merge " . + $row['Name'] . " [2] into " . $merge_into . + " [3]:\n\n" . $comments . "\n\n" . + "[1] " . $AUR_LOCATION . get_user_uri($username) . "\n" . + "[2] " . $AUR_LOCATION . get_pkgbase_uri($row['Name']) . "\n" . + "[3] " . $AUR_LOCATION . get_pkgbase_uri($merge_into) . "\n"; + } else { + $body = + $username . " [1] filed a " . $type . " request for " . + $row['Name'] . " [2]:\n\n" . $comments . "\n\n" . + "[1] " . $AUR_LOCATION . get_user_uri($username) . "\n" . + "[2] " . $AUR_LOCATION . get_pkgbase_uri($row['Name']) . "\n"; + } $body = wordwrap($body, 70); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8\r\n" . -- 2.0.1
participants (1)
-
Lukas Fleischer