From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id 0INWCmnWVmSDiAAASxT56A (envelope-from ) for ; Sun, 07 May 2023 00:36:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id iFRLCmnWVmTi7wAAauVa8A (envelope-from ) for ; Sun, 07 May 2023 00:36:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 8FA2A269FC for ; Sun, 7 May 2023 00:36:24 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pvQVY-0004O5-5B; Sat, 06 May 2023 18:36:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvQVW-0004Nq-UI for guix-patches@gnu.org; Sat, 06 May 2023 18:36:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pvQVW-0003rF-M9 for guix-patches@gnu.org; Sat, 06 May 2023 18:36:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pvQVW-00025x-Hl for guix-patches@gnu.org; Sat, 06 May 2023 18:36:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#63215] [PATCH 2/2] client: Cc issue participants when sending email. Resent-From: Arun Isaac Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 06 May 2023 22:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63215 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 63215@debbugs.gnu.org Cc: Arun Isaac Received: via spool by 63215-submit@debbugs.gnu.org id=B63215.16834125528026 (code B ref 63215); Sat, 06 May 2023 22:36:02 +0000 Received: (at 63215) by debbugs.gnu.org; 6 May 2023 22:35:52 +0000 Received: from localhost ([127.0.0.1]:35931 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvQVL-00025O-GO for submit@debbugs.gnu.org; Sat, 06 May 2023 18:35:51 -0400 Received: from mugam.systemreboot.net ([139.59.75.54]:45686) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvQVG-00024x-Lo for 63215@debbugs.gnu.org; Sat, 06 May 2023 18:35:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=systemreboot.net; s=default; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=PGDQSYWuAXhby8sUkF9BAE9oxsUFfn28EdmcKc1AP9Q=; b=odEviq/8l8VWadduh1IOmE0Ftx E0qcAIXg6tf0bw90pF1iwQnc3eZQNgJLwllIm8FVKFsHz7u7UL1B9u0gegL62pIFPIJ8zpqhF/J1G 8vTJy8KVln2ZZa8nsXQVX/uyDUzd4GHNGCGEzm+bukTlpk6yRSxYX9TZpm9mzD2diZbZwkRIQ9jR4 seP71e7bmqgnI8tE6burLN03yWkOl/ySJyqyrQ2rEMkXjihq1V0fzY1FgxU475NOzHeJB5I9694jU OAHMu8SFnaha13pwU+oahK3lvaJrRV8ZuEzFV3BbaLkRd7n45p7azXvCY6T5KUz98IdBpzcnp9YG6 ukeKrwPw==; Received: from [192.168.2.1] (port=41376 helo=localhost.localdomain) by systemreboot.net with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1pvQVD-0005PK-0x; Sat, 06 May 2023 23:35:43 +0100 From: Arun Isaac Date: Sat, 6 May 2023 23:35:20 +0100 Message-Id: <20230506223520.27933-2-arunisaac@systemreboot.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230506223520.27933-1-arunisaac@systemreboot.net> References: <20230506223520.27933-1-arunisaac@systemreboot.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1683412585; a=rsa-sha256; cv=none; b=t4WN80v3pXfED0Phb7gSEprAs134QJuS9SX869/b2WNR6H0TrQqBCzFIoZqGz7uIXf1Ba3 fBZ+2hSJvvuCPX+cHZ4sKkO95At1eUL46wY/6FSGxPgdmGzYugpEWlgYMHi81QE90SRciE MIGGvsb8I78Syy+queb9KwrANhXp6ywOvoUr+nFvE1ZIiI3YTiL2UdcnCdv/zOdsvPoN6Q Gx1uLChhbfOE7ijmbElZZFQiqy7ZlHNt7Hw4eojYLGgJXkn7DTeTEDV9LKKDDHCvb3+cSn d3tePTNHzIfUkNu4N2siUMX4f6TGB4/h+RqfMUZpE+0TDbMQxmU+lw8DIvc8+g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b="odEviq/8"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1683412584; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PGDQSYWuAXhby8sUkF9BAE9oxsUFfn28EdmcKc1AP9Q=; b=d3Wi4haMGRJYY2fsmTFMUfxDAnmmQKxIwTgAJCZL5BHhobdzIzpo1jiCP7lLqyaNmSaSbE AvDLk86VsF71j5prwkrIQOa7SnnVcBF4Dc1/C+yucBh71u3taUiByv7oTwg82gUTIwvt/A FcbHupSCiVXElYHmRqd8mLr9ZVy+99/JW2oNdoc3igqyQzAaw8cSPrESOXutPv4a3wi1uT E5d+8/76+Oaxarlu7H9dKnbDdFEQ17WMBrkjP6v1byljXxxPrG3k0FPZSiG/AiA0fSdCEa TszWPS6zJNp/vGxUTYRhmYbkPOeoWv0eFqG+OEE6VRTOLQgimcQhpzUZG6Pc5g== X-Migadu-Spam: Yes X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=systemreboot.net header.s=default header.b="odEviq/8"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=systemreboot.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Spam: Yes X-Migadu-Spam-Score: 8.80 X-Spam-Score: 8.80 X-Migadu-Queue-Id: 8FA2A269FC X-TUID: 4J5GOngcNgDN * mumi/client.scm: Import (srfi srfi-1). (reply-email-headers): New function. (send-email): Call reply-email-headers. * tests/client.scm ("send patches to existing issue", "send single patch to existing issue"): Stub reply-email-headers. ("send patch to existing issue and Cc other participants"): New test. --- mumi/client.scm | 36 ++++++++++++++++++++++++++++++++---- tests/client.scm | 25 +++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/mumi/client.scm b/mumi/client.scm index 2750836..7ba47e6 100644 --- a/mumi/client.scm +++ b/mumi/client.scm @@ -18,6 +18,7 @@ (define-module (mumi client) #:use-module (rnrs io ports) + #:use-module (srfi srfi-1) #:use-module (srfi srfi-19) #:use-module (srfi srfi-26) #:use-module (srfi srfi-43) @@ -236,15 +237,42 @@ OPTIONS. Return the message ID of the first email sent." (display (get-string-all port)) message-id))))) +(define (reply-email-headers issue-number) + "Return an association list of email headers when replying to +ISSUE-NUMBER." + (let ((messages + (assoc-ref + (assoc-ref + (graphql-http-get (graphql-endpoint) + `(document + (query (#(issue #:number ,issue-number) + (messages (from name address) + date))))) + "issue") + "messages"))) + ;; When sending email to an issue, we Cc all issue participants. + ;; TODO: Also add an In-Reply-To header. + `((x-debbugs-cc + . ,(delete-duplicates + (map (lambda (message) + (let ((from (assoc-ref message "from"))) + (string-append (assoc-ref from "name") + " <" (assoc-ref from "address") ">"))) + (vector->list messages))))))) + (define (send-email patches) "Send PATCHES via email." (if (current-issue-number) ;; If an issue is current, send patches to that issue's email ;; address. - (git-send-email (string-append (number->string (current-issue-number)) - "@" - (client-config 'debbugs-host)) - patches) + (let ((issue-number (current-issue-number))) + (git-send-email (string-append (number->string issue-number) + "@" + (client-config 'debbugs-host)) + patches + (map (cut string-append "--add-header=X-Debbugs-Cc: " <>) + (assq-ref (reply-email-headers issue-number) + 'x-debbugs-cc)))) (match patches ;; If it's a single patch, send it to the patch email address ;; and be done with it diff --git a/tests/client.scm b/tests/client.scm index 94c8c5d..1d40c10 100644 --- a/tests/client.scm +++ b/tests/client.scm @@ -90,6 +90,8 @@ called with." (lambda () (with-variables (list (cons (var@@ (mumi client) current-issue-number) (const 12345)) + (cons (var@@ (mumi client) reply-email-headers) + (const '((x-debbugs-cc)))) client-config-stub do-not-poll-server-for-issue-number) (cut (@@ (mumi client) send-email) @@ -116,6 +118,29 @@ called with." (lambda () (with-variables (list (cons (var@@ (mumi client) current-issue-number) (const 12345)) + (cons (var@@ (mumi client) reply-email-headers) + (const '((x-debbugs-cc)))) + client-config-stub + do-not-poll-server-for-issue-number) + (cut (@@ (mumi client) send-email) + (list "foo.patch"))))))) + +(test-equal "send patch to existing issue and Cc other participants" + '(("git" "send-email" + "--to=12345@example.com" + "--add-header=X-Debbugs-Cc: John Doe " + "--add-header=X-Debbugs-Cc: Mary Smith " + "foo.patch")) + (map (match-lambda + ((command _) command)) + (trace-calls (var@@ (mumi client) call-with-input-pipe) + (lambda () + (with-variables (list (cons (var@@ (mumi client) current-issue-number) + (const 12345)) + (cons (var@@ (mumi client) reply-email-headers) + (const `((x-debbugs-cc + "John Doe " + "Mary Smith ")))) client-config-stub do-not-poll-server-for-issue-number) (cut (@@ (mumi client) send-email) -- 2.39.2