Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

URL for thumbnails in mail notification doesn't populate the method variable with scale from notif.html #12506

Closed
tgurr opened this issue Apr 20, 2022 · 3 comments · Fixed by #12510
Assignees
Labels
S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@tgurr
Copy link

tgurr commented Apr 20, 2022

Description

Link for thumbnails in mail notification doesn't populate the method variable resulting in errcode: M_NOT_FOUND

Inspecting the mails HTML code reveals the following link to the preview image:

https://matrix.domain.corporate/_matrix/media/v1/thumbnail/domain.corporate/DAqDEJPvGLMpWPidjpgBfgaU?width=640&height=480&method=

which results in

{"errcode":"M_NOT_FOUND","error":"Not found [b'domain.corporate', b'DAqDEJPvGLMpWPidjpgBfgaU']"}

when opened in a browser window.

When manually adding the scale property which is present in notif.html mail template, code

                    {%- elif message.msgtype == "m.image" and message.image_url %}
                        <img src="{{ message.image_url|mxc_to_http(640, 480, scale) }}" />

to the URL like

https://matrix.domain.corporate/_matrix/media/v1/thumbnail/domain.corporate/DAqDEJPvGLMpWPidjpgBfgaU?width=640&height=480&method=scale

the preview thumbnail is shown properly.

Steps to reproduce

  • enable mail notifications
  • be unavailable
  • have someone send you a message with an image
  • see the preview/link in the sent notification mail not working

Version information

  • Homeserver: local instance

If not matrix.org:

  • Version: {"server_version":"1.57.0","python_version":"3.9.10"}

  • Install method: package manager

  • Platform: Exherbo Linux / virtual machine

@tgurr tgurr changed the title URL for thumbnails in mail notification doesn't include the scale variable from notif.html URL for thumbnails in mail notification doesn't populate the method variable with scale from notif.html Apr 20, 2022
@clokep
Copy link
Contributor

clokep commented Apr 20, 2022

When manually adding the scale property which is present in notif.html mail template, code

                    {%- elif message.msgtype == "m.image" and message.image_url %}
                        <img src="{{ message.image_url|mxc_to_http(640, 480, scale) }}" />

I think this can be fixed by putting single quotes around the scale (currently JInja is treating it as a variable, which doesn't exist, so falls back to an empty string). If you change notif.html to:

                    {%- elif message.msgtype == "m.image" and message.image_url %}
                        <img src="{{ message.image_url|mxc_to_http(640, 480, 'scale') }}" />

does it work?

@clokep clokep added S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Apr 20, 2022
@tgurr
Copy link
Author

tgurr commented Apr 20, 2022

does it work?

Yes it does, works like expected with the change you suggested.

@clokep
Copy link
Contributor

clokep commented Apr 20, 2022

Great! Should be fixed by #12510 then!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants