Fix breaking on HTML email without images (#22143)

* Fix breaking on HTML email without images

If using html emails with no images the code breaks since it is not tested for empty (uninitialized) key images.

* fixed long line

* Implemented suggested better solution

Better solution to allow data -> html email without images.

* Protecting data -> without html key from crashing

If the data key does not contain the html key, sending the email would crash this "script". Preventing this by returning an default empty array.
This commit is contained in:
CV 2019-03-19 22:37:12 +01:00 committed by Jason Hu
parent 0344c761fc
commit db07e45df8

View file

@ -151,10 +151,10 @@ class MailNotificationService(BaseNotificationService):
if data: if data:
if ATTR_HTML in data: if ATTR_HTML in data:
msg = _build_html_msg( msg = _build_html_msg(
message, data[ATTR_HTML], images=data.get(ATTR_IMAGES)) message, data[ATTR_HTML], images=data.get(ATTR_IMAGES, []))
else: else:
msg = _build_multipart_msg( msg = _build_multipart_msg(
message, images=data.get(ATTR_IMAGES)) message, images=data.get(ATTR_IMAGES, []))
else: else:
msg = _build_text_msg(message) msg = _build_text_msg(message)