{%- set activities = (activities or []) + get_ui_elements('email_activities', state) -%} {%- if thread|length > 1 %} {%- do activities.extend(get_ui_elements('thread_activities', state)) %} {%- endif %} {%- set from = metadata.from %} {%- set allow_html = ((message.crypto.encryption.status == 'none') or not config.prefs.encrypted_block_html) %} {%- set allow_images = ((message.crypto.encryption.status == 'none') or not config.prefs.encrypted_block_web) %} {%- set encryption_status = [] %} {%- set signature_status = [] %} {%- set special_text_parts = [] %} {%- macro msg_crypto(part, forcedisplay) %} {#- # Parts that do not have own crypto attribute inherit from message itself # Watch for changes to the "status" which is present in each encryption and # signature section - if either has changed, then we have moved from # one security context to the next, and need to let the user know. #} {%- set part_encryption = (part.crypto and part.crypto.encryption or message.crypto.encryption) %} {%- set part_signature = (part.crypto and part.crypto.signature or message.crypto.signature) %} {%- set encryption = show_text_part_encryption(part_encryption and part_encryption.status) %} {%- set signature = show_text_part_signature(part_signature and part_signature.status) %} {%- if encryption_status and (forcedisplay or part_encryption.status != encryption_status[-1]) %}
{%- elif signature_status and part_signature.status != signature_status[-1] %}
{%- else %}
{%- endif %} {%- if part_encryption %} {%- if not encryption_status or forcedisplay or part_encryption.status != encryption_status[-1] %} {{ encryption.text }} {%- endif %} {%- do encryption_status.append(part_encryption.status) %} {%- endif %} {%- if part_signature %} {%- if not signature_status or part_signature.status != signature_status[-1] %} {{ signature.text }} {%- endif %} {%- do signature_status.append(part_signature.status) %} {%- endif %}
{%- endmacro %} {%- set mailer_daemon = ('mailer-daemon@' in from.address) or ('MAILER-DAEMON@' in from.address) or ('postmaster@' in from.address) %} {%- set risky_content = config.prefs.antiphishing and (metadata.flags.spam or mailer_daemon or message.trust.problem or (message.trust.warning and message.attachments)) and True %} {%- set risky_links = config.prefs.antiphishing and (risky_content or message.trust.trust_unknown) and True %} {%- macro risky_content_classes() %} {%- if risky_content %} risky hide{% endif -%} {%- endmacro %} {%- macro msg_warning(reason, nolinks, noatts, actions) %}
{{ reason -}} {%- if nolinks and noatts and message.attachments %} {{_("Blocked attachments, replies, and links.")}} {%- elif noatts and message.attachments %} {{_("Attachments and replies are blocked.")}} {%- elif nolinks %} {{_("Links are blocked.")}}{%- endif %}
{%- for act in actions %}{% if not act.hide %} {{ act.msg }} {% endif %}{%- endfor %}
{%- endmacro %}
{%- if config.prefs.antiphishing %} {%- if metadata.flags.spam %} {{- msg_warning("This message is probably spam.", True, True, [ {"icon": "not-spam", "msg": _("Remove from spam")}, {"icon": "attachment", "msg": _("Show risky content")}, ]) -}} {%- elif message.trust.problem or (message.trust.warning and message.attachments) %} {{- msg_warning((message.trust.problem or message.trust.warning) + ".", True, True, [ {"icon": "attachment", "act": "Mailpile.stuff();", "msg": _("Show risky content")}, {"icon": "spam", "msg": _("Send to spam")}, ]) -}} {%- elif risky_content or risky_links %} {{- msg_warning("This sender's reputation is unknown.", True, risky_content, [ {"icon": "groups", "msg": _("Add to contacts"), "hide": (mailer_daemon or metadata.flags.from_contact) and True or False }, {"icon": "attachment", "msg": _("Show risky content")}, {"icon": "spam", "msg": _("Send to spam")}, ]) -}} {%- endif %} {%- endif %} {%- if message.text_parts %} {%- set last_part = message.text_parts|length - 1 %} {%- for part in message.text_parts %}
{%- if part.data|trim %} {{- msg_crypto(part, False) }} {%- autoescape false %} {%- set part_text = part.data|nice_text|e|urlize|fix_urls(40, risky_links) %} {%- if part.type in ("text", "pgpsignedtext") %}
{{ part_text|to_br }}
{%- elif part.type in ("pgptext",) %} {%- if part.crypto.encryption.status in ("lockedkey", "missingkey", "error") %} {%- set failed_crypto = part.crypto.encryption %} {%- include("partials/thread_message_cryptofail.html") %} {%- else %}
{{ part_text|to_br }}
{%- endif %} {%- elif part.type in ("pgpbegin", "pgpend") %}
{{part.data}}
{%- elif part.type == "quote" %} {# If this is the 2nd-to-last part, and the LAST part is a quote or signature, we shall also hide. #} {%- if loop.index == (loop.length - 1) and message.text_parts[last_part].type in ("signature", "quote") -%} {% do special_text_parts.append("quote") %}
{{ part_text|to_br }}
{# If this part is a quote at end of message, hide #} {%- elif loop.last %} {%- do special_text_parts.append("quote") %}
{{ part_text|to_br }}
{%- else %}
{{ part_text|to_br }}
{%- endif -%} {%- elif part.type == "signature" %} {%- do special_text_parts.append("signature") %}
{{ part_text|to_br }}
{%- else %}
{{_("Unknown Text Part")}}
{%- endif %} {%- endautoescape %} {%- endif %}
{%- endfor %} {%- if allow_html %}{%- for part in message.html_parts %}
{{ msg_crypto(part, loop.first) }}
{{ _("HTML rendering requires Javascript, sorry!") }}
{%- endfor %}{%- endif %} {%- else %} {%- if message.crypto.encryption.status in ("lockedkey", "missingkey", "error") %} {%- set failed_crypto = message.crypto.encryption %} {%- include("partials/thread_message_cryptofail.html") %} {%- elif not message.attachments %}
{{_("Message content is empty")}}
{%- endif %} {%- endif %} {%- if message.attachments %}
{%- endif %}
    {%- if "quote" in special_text_parts or "signature" in special_text_parts %}
  • ····
  • {%- endif %}