fix: add recipients to BCC when email is hidden

Package requests are sent to the ML as well as users (CC).
For those who chose to hide their mail address,
we should add them to the BCC list instead.

Signed-off-by: moson-mo <mo-son@mailbox.org>
This commit is contained in:
moson-mo 2023-07-01 12:55:14 +02:00 committed by moson
parent 9fe8d524ff
commit f3f8c0a871
No known key found for this signature in database
GPG key ID: 4A4760AB4EE15296
4 changed files with 68 additions and 6 deletions

View file

@ -479,6 +479,44 @@ def test_close_request_comaintainer_cc(
assert email.headers.get("Cc") == ", ".join([user.Email, user2.Email])
def test_open_close_request_hidden_email(
user2: User, pkgreq: PackageRequest, pkgbases: list[PackageBase]
):
pkgbase = pkgbases[0]
# Enable the "HideEmail" option for our requester
with db.begin():
user2.HideEmail = 1
# Send an open request notification.
notif = notify.RequestOpenNotification(
user2.ID, pkgreq.ID, pkgreq.RequestType.Name, pkgbase.ID
)
# Make sure our address got added to the bcc list
assert user2.Email in notif.get_bcc()
notif.send()
assert Email.count() == 1
email = Email(1).parse()
# Make sure we don't have our address in the Cc header
assert user2.Email not in email.headers.get("Cc")
# Create a closure notification on the pkgbase we just opened.
notif = notify.RequestCloseNotification(user2.ID, pkgreq.ID, "rejected")
# Make sure our address got added to the bcc list
assert user2.Email in notif.get_bcc()
notif.send()
assert Email.count() == 2
email = Email(2).parse()
# Make sure we don't have our address in the Cc header
assert user2.Email not in email.headers.get("Cc")
def test_close_request_closure_comment(
user: User, user2: User, pkgreq: PackageRequest, pkgbases: list[PackageBase]
):