feat: Set reply-to header for notifications to ML

We can set the "reply-to" header to the "to" address for any mails
that go out to the aur-requests mailing list.

Signed-off-by: moson <moson@archlinux.org>
This commit is contained in:
moson 2023-11-28 09:33:02 +01:00
parent 4637b2edba
commit 783422369e
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
2 changed files with 19 additions and 1 deletions

View file

@ -13,6 +13,7 @@ from aurweb.testing.smtp import FakeSMTP, FakeSMTP_SSL
aur_location = config.get("options", "aur_location")
aur_request_ml = config.get("options", "aur_request_ml")
aur_reply_to = config.get("notifications", "reply-to")
@pytest.fixture(autouse=True)
@ -411,6 +412,7 @@ def test_open_close_request(
email = Email(1).parse()
assert email.headers.get("To") == aur_request_ml
assert email.headers.get("Reply-to") == aur_request_ml
assert email.headers.get("Cc") == ", ".join([user.Email, user2.Email])
expected = f"[PRQ#{pkgreq.ID}] Orphan Request for {pkgbase.Name}"
assert email.headers.get("Subject") == expected
@ -432,6 +434,7 @@ This is a request test comment.
email = Email(2).parse()
assert email.headers.get("To") == aur_request_ml
assert email.headers.get("Reply-to") == aur_request_ml
assert email.headers.get("Cc") == ", ".join([user.Email, user2.Email])
expected = f"[PRQ#{pkgreq.ID}] Orphan Request for {pkgbase.Name} Rejected"
assert email.headers.get("Subject") == expected
@ -450,6 +453,7 @@ Request #{pkgreq.ID} has been rejected by {user2.Username} [1].
email = Email(3).parse()
assert email.headers.get("To") == aur_request_ml
assert email.headers.get("Reply-to") == aur_request_ml
assert email.headers.get("Cc") == ", ".join([user.Email, user2.Email])
expected = f"[PRQ#{pkgreq.ID}] Orphan Request for " f"{pkgbase.Name} Accepted"
assert email.headers.get("Subject") == expected
@ -476,6 +480,7 @@ def test_close_request_comaintainer_cc(
email = Email(1).parse()
assert email.headers.get("To") == aur_request_ml
assert email.headers.get("Reply-to") == aur_request_ml
assert email.headers.get("Cc") == ", ".join([user.Email, user2.Email])
@ -530,6 +535,7 @@ def test_close_request_closure_comment(
email = Email(1).parse()
assert email.headers.get("To") == aur_request_ml
assert email.headers.get("Reply-to") == aur_request_ml
assert email.headers.get("Cc") == ", ".join([user.Email, user2.Email])
expected = f"[PRQ#{pkgreq.ID}] Orphan Request for {pkgbase.Name} Accepted"
assert email.headers.get("Subject") == expected
@ -721,6 +727,7 @@ def test_notification_defaults():
assert notif.get_refs() == tuple()
assert notif.get_headers() == dict()
assert notif.get_cc() == list()
assert notif.get_reply_to() == aur_reply_to
def test_notification_oserror(user: User, caplog: pytest.LogCaptureFixture):