use email namespace in configuration

This is for all configuration related to sending emails, not for e.g.
the default QA contact. By chance, it fixes a problem in the default
configuration where the mail templates ended up in the pdc_types
subtree.

Signed-off-by: Nils Philippsen <nils@redhat.com>
This commit is contained in:
Nils Philippsen 2019-11-22 16:42:04 +01:00
parent 7821f08e2e
commit 78434ffbfd
2 changed files with 22 additions and 21 deletions

View file

@ -1,11 +1,9 @@
environment = "staging" environment = "staging"
send_email = false
email_from = "accounts@fedoraproject.org"
data_cache = "/var/tmp/pagure_sync_bz.json" data_cache = "/var/tmp/pagure_sync_bz.json"
notify_emails = [ bz_maintainer_change_comment = """
"root@localhost.localdomain", This package has changed maintainer in the Fedora.
] Reassigning to the new maintainer of this component.
"""
[products] [products]
"Fedora" = "Fedora" "Fedora" = "Fedora"
@ -29,22 +27,23 @@ notify_emails = [
"modules" = "module" "modules" = "module"
"container" = "container" "container" = "container"
bz_maintainer_change_comment = """ [email]
This package has changed maintainer in the Fedora. send_mails = false
Reassigning to the new maintainer of this component. from = "accounts@fedoraproject.org"
""" notify_admins = [
"root@localhost.localdomain",
]
## EMAIL TEMPLATES [email.templates]
admin_notification = """
tmpl_admin_email = """
The following errors were encountered while updating bugzilla with information The following errors were encountered while updating bugzilla with information
from the Package Database. Please have the problems taken care of: from the Package Database. Please have the problems taken care of:
{errors} {errors}
""" """
# User email for invalid setup # User email for invalid setup
tmpl_user_email = """Greetings. user_notification = """Greetings.
You are receiving this email because there's a problem with your You are receiving this email because there's a problem with your
bugzilla.redhat.com account. bugzilla.redhat.com account.

View file

@ -561,11 +561,11 @@ class DistgitBugzillaSync:
if notify_user: if notify_user:
send_email( send_email(
self.env['email_from'], self.env['email']['from'],
[user_email], [user_email],
subject='Please fix your bugzilla.redhat.com account', subject='Please fix your bugzilla.redhat.com account',
message=self.env['tmpl_user_email'], message=self.env['email']['templates']['user_notification'],
cc_address=self.env['notify_emails'], cc_address=self.env['email']['notify_admins'],
) )
new_data[user_email] = { new_data[user_email] = {
@ -875,10 +875,12 @@ class DistgitBugzillaSync:
else: else:
self.notify_users(errors) self.notify_users(errors)
send_email( send_email(
self.env['email_from'], self.env['email']['from'],
self.env['notify_emails'], self.env['email']['notify_admins'],
'Errors while syncing bugzilla with the PackageDB', 'Errors while syncing bugzilla with the PackageDB',
self.env['tmpl_admin_email'].format(errors='\n'.join(errors)) self.env['email']['templates']['admin_notification'].format(
errors='\n'.join(errors)
)
) )
else: else:
with open(self.env['data_cache'], 'w') as stream: with open(self.env['data_cache'], 'w') as stream: