#8852: fix(matrix): Await mxcToHttp to properly detect authenticated media endpoint
channel: matrix
stale
Cluster:
Matrix Media Handling Fixes
## Problem
The Matrix SDK's `getMediaEndpointPrefix()` method is async, but `mxcToHttp()` wasn't being awaited, causing it to return a Promise instead of the actual URL string.
This resulted in improper media endpoint detection and download failures.
## Solution
Add `await` to the `mxcToHttp()` call to properly detect the authenticated media endpoint:
```typescript
const url = await params.client.mxcToHttp(params.mxcUrl);
```
## Impact
- Fixes media downloads on homeservers using MSC3916 authenticated media
- Ensures proper endpoint selection (_matrix/media vs _matrix/client/v1/media)
- No breaking changes for non-authenticated homeservers
## Related
- MSC3916: Authenticated media
- Part of Matrix media download improvements
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates Matrix media downloading to `await` the Matrix SDK’s async `mxcToHttp()` helper when determining the media endpoint prefix, preventing a Promise from being treated as a URL string. The change is localized to the Matrix media monitor code (`extensions/matrix/src/matrix/monitor/media.ts`) and aligns endpoint detection with MSC3916 authenticated media behavior while keeping download logic (via `downloadContent`) unchanged.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is a single, correct await added to match an async API contract; it fixes a concrete runtime bug (Promise used where string expected) without altering downstream download/decrypt behavior.
- No files require special attention
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#10313: fix(matrix): fallback to authenticated media download (Matrix v1.11+)
by iter-next · 2026-02-06
86.4%
#10721: fix for matrix media: destructure downloadContent return value in m...
by mklasen · 2026-02-06
78.2%
#13026: matrix: optionally include media metadata in message.read
by yamoroc · 2026-02-10
72.4%
#2902: fix(matrix): check if requestOwnUserVerification exists before calling
by dokterdok · 2026-01-27
72.1%
#7842: Fix Matrix mention detection for Element client (formatted_body links)
by emadomedher · 2026-02-03
71.3%
#11086: fix(mattermost): allow private network for inbound media download
by oskarmodig · 2026-02-07
70.8%
#22389: Fix: Matrix plugin not sending images from content blocks
by fryccerGit · 2026-02-21
70.6%
#20278: Fix/matrix missing bot sdk dependency
by saurav470 · 2026-02-18
70.5%
#9817: fix(media): resolve relative paths before reading local files (#8759)
by lailoo · 2026-02-05
70.1%
#20025: Fix Matrix messages silently dropped due to zero startup grace
by Clawborn · 2026-02-18
70.0%