Skip to content

Commit 5c47ded

Browse files
committed
reorzanize collecting template data
1 parent 6ea9a02 commit 5c47ded

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

intelmq/bots/outputs/smtp_batch/output.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,18 @@ def prepare_mails(self) -> Iterable[Mail]:
330330

331331
# collect all data which must be the same for all events of the
332332
# bucket and thus can be used for templating
333-
template_data = {}
334-
# only collect if templating is enabled (save the memory otherwise)
333+
template_keys = ['source.abuse_contact']
334+
# only collect if templating is enabled (save the memory otherwise)+
335335
if jinja2 and self.templating and any(self.templating.values()):
336-
template_data = {
337-
k.replace(".", "_"): lines[0][k]
338-
for k in ["source.abuse_contact"] + self.additional_grouping_keys
339-
if k in rows_output[0]
340-
}
336+
template_keys.extend(self.additional_grouping_keys)
341337

342-
email_to = template_data["source_abuse_contact"]
338+
template_data = {
339+
k.replace(".", "_"): lines[0][k]
340+
for k in template_keys
341+
if k in rows_output[0]
342+
}
343+
344+
email_to = template_data["source.abuse_contact"]
343345
filename = f'{time.strftime("%y%m%d")}_{count}_events'
344346
path = NamedTemporaryFile().name
345347

0 commit comments

Comments
 (0)