Scheduled exports: Set owner to cc instead of to if there is an explicit recipient (#3045)

This commit is contained in:
Raphael Michel
2023-01-23 11:10:47 +01:00
committed by GitHub
parent 785cc49a2e
commit fdc15a753c
2 changed files with 17 additions and 7 deletions

View File

@@ -228,10 +228,20 @@ def _run_scheduled_export(schedule, context: Union[Event, Organizer], exporter,
else:
schedule.error_counter = 0
schedule.save(update_fields=['error_counter'])
to = [r for r in schedule.mail_additional_recipients.split(",") if r]
cc = [r for r in schedule.mail_additional_recipients_cc.split(",") if r]
bcc = [r for r in schedule.mail_additional_recipients_bcc.split(",") if r]
if to:
# If there is an explicit To, the owner is Cc. Otherwise, the owner is To. Yes, this is
# purely cosmetical and has policital reasons.
cc.append(schedule.owner.email)
else:
to.append(schedule.owner.email)
mail(
email=[schedule.owner.email] + [r for r in schedule.mail_additional_recipients.split(",") if r],
cc=[r for r in schedule.mail_additional_recipients_cc.split(",") if r],
bcc=[r for r in schedule.mail_additional_recipients_bcc.split(",") if r],
email=to,
cc=cc,
bcc=bcc,
subject=schedule.mail_subject,
template=LazyI18nString(schedule.mail_template),
context=get_email_context(event=context) if isinstance(context, Event) else {},