Skip to content
Snippets Groups Projects
Unverified Commit 4136255d authored by Patrick Cloke's avatar Patrick Cloke Committed by GitHub
Browse files

Ensure that a URL exists in the content during push. (#8965)

This fixes an KeyError exception, after this PR the content
is just considered unknown.
parent a7a91391
No related branches found
No related tags found
No related merge requests found
Fix a longstanding bug where a `m.image` event without a `url` would cause errors on push.
...@@ -486,7 +486,11 @@ class Mailer: ...@@ -486,7 +486,11 @@ class Mailer:
def add_image_message_vars( def add_image_message_vars(
self, messagevars: Dict[str, Any], event: EventBase self, messagevars: Dict[str, Any], event: EventBase
) -> None: ) -> None:
messagevars["image_url"] = event.content["url"] """
Potentially add an image URL to the message variables.
"""
if "url" in event.content:
messagevars["image_url"] = event.content["url"]
async def make_summary_text( async def make_summary_text(
self, self,
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
{{ message.body_text_html }} {{ message.body_text_html }}
{%- elif message.msgtype == "m.notice" %} {%- elif message.msgtype == "m.notice" %}
{{ message.body_text_html }} {{ message.body_text_html }}
{%- elif message.msgtype == "m.image" %} {%- elif message.msgtype == "m.image" and message.image_url %}
<img src="{{ message.image_url|mxc_to_http(640, 480, scale) }}" /> <img src="{{ message.image_url|mxc_to_http(640, 480, scale) }}" />
{%- elif message.msgtype == "m.file" %} {%- elif message.msgtype == "m.file" %}
<span class="filename">{{ message.body_text_plain }}</span> <span class="filename">{{ message.body_text_plain }}</span>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment