Skip to content

feat: add matrix content scanner support#2332

Open
kamor-famedly wants to merge 3 commits into
mainfrom
khalil/content-scanner-support
Open

feat: add matrix content scanner support#2332
kamor-famedly wants to merge 3 commits into
mainfrom
khalil/content-scanner-support

Conversation

@kamor-famedly
Copy link
Copy Markdown
Contributor

This PR implements support for routing media downloads through a Matrix content scanner proxy.

When contentScannerConfig is set, MXC download and thumbnail URLs are resolved against the scanner endpoints. downloadAndDecryptAttachment() now also supports scanner-backed downloads for encrypted
attachments by posting the encrypted file metadata to download_encrypted, then decrypting the returned bytes client-side as before.

The implementation was tested end-to-end against our staging server using the local scanner proxy tool at tool/content_scanner_proxy.dart.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

❌ Patch coverage is 75.30864% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.29%. Comparing base (19596e3) to head (14369da).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
lib/src/event.dart 39.28% 17 Missing ⚠️
lib/src/utils/uri_extension.dart 85.71% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2332      +/-   ##
==========================================
+ Coverage   53.49%   58.29%   +4.80%     
==========================================
  Files         160      161       +1     
  Lines       19854    19912      +58     
==========================================
+ Hits        10621    11608     +987     
+ Misses       9233     8304     -929     
Files with missing lines Coverage Δ
lib/src/client.dart 77.81% <ø> (+21.67%) ⬆️
lib/src/utils/content_scanner_config.dart 100.00% <100.00%> (ø)
lib/src/utils/uri_extension.dart 57.14% <85.71%> (+8.20%) ⬆️
lib/src/event.dart 80.88% <39.28%> (+1.36%) ⬆️

... and 32 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 19596e3...14369da. Read the comment docs.

Copy link
Copy Markdown
Contributor

@krille-chan krille-chan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kamor-famedly can you link an issue here?

@@ -0,0 +1,605 @@
#!/usr/bin/env dart
// ignore_for_file: avoid_print
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to move this to /test/tool? So we don't introduce another root level directory

Comment thread lib/src/event.dart Outdated
if (isEncrypted && !room.client.encryptionEnabled) {
throw ('Encryption is not enabled in your Client.');
}
// File attachments use per-file keys, independent of room encryption state.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see why this was removed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I treated file encryption as seperate from room/events encryption.
I think this is more appropriate

if (isEncrypted && !room.client.fileEncryptionEnabled) {
throw ('Encryption is not enabled in your Client.');
}

@kamor-famedly kamor-famedly force-pushed the khalil/content-scanner-support branch from c0d2a9e to 14369da Compare May 14, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants