Skip to content

Initial content scanner integration#7139

Merged
jmartinesp merged 16 commits into
developfrom
feat/content-scanner-integration
Jul 8, 2026
Merged

Initial content scanner integration#7139
jmartinesp merged 16 commits into
developfrom
feat/content-scanner-integration

Conversation

@jmartinesp

@jmartinesp jmartinesp commented Jul 1, 2026

Copy link
Copy Markdown
Member

Content

Create the base APIs to be able to use an optional content scanner for the media in the app:

  • Create :features:contentscanner modules.
  • Create a ContentScanner wrapper for the RustContentScanner one.
  • Create a ContentScannerUrlProvider interface and implement a noop version for the FOSS app so we don't instantiate a content scanner in that case.
  • Add the shared code to use a provided content scanner (coming from the enterprise code) to set it up in the SDK and expose it in the @SessionScope.
  • Split the code for fetching the Element well-known and caching it so the caching part can be used by other components - it will be used by enterprise.

Motivation and context

Closes #7122.

Tests

Check with FOSS that everything works as before.

With Pro, use the counterpart branch to check the element-well known file is fetched. Sadly, we have no example HS with this value, so the most you can probably do is using Proxyman or some other MITM proxy to override the response for that endpoint and point to a content scanner instance you have running somewhere. Details on how to run a content scanner server are detailed in the parent story.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 15

Checklist

  • I am aware of the etiquette.
  • This PR was made with the help of AI:
    • Yes. In this case, please request a review by Copilot.
    • No.
  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly defines what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/cfBk9t

@jmartinesp jmartinesp force-pushed the feat/content-scanner-integration branch from d227064 to e96b0f2 Compare July 1, 2026 20:44
@jmartinesp jmartinesp added the PR-Wip For anything that isn't ready to ship and will be enabled at a later date label Jul 2, 2026
@jmartinesp jmartinesp force-pushed the feat/content-scanner-integration branch from ca86d89 to 1df9a59 Compare July 2, 2026 06:24
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.98165% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.57%. Comparing base (7c3d1e2) to head (8bf068e).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
...d/libraries/matrix/impl/RustMatrixClientFactory.kt 33.33% 5 Missing and 3 partials ⚠️
...wellknown/impl/DefaultSessionWellknownRetriever.kt 84.00% 2 Missing and 2 partials ⚠️
...ibraries/matrix/impl/scanner/RustContentScanner.kt 72.72% 1 Missing and 2 partials ⚠️
...atures/wellknown/test/FakeElementWellknownStore.kt 80.00% 3 Missing ⚠️
...x/impl/scanner/DefaultContentScannerUrlProvider.kt 0.00% 2 Missing ⚠️
...id/libraries/matrix/impl/di/SessionMatrixModule.kt 0.00% 1 Missing ⚠️
...ibraries/matrix/test/scanner/FakeContentScanner.kt 50.00% 1 Missing ⚠️
...element/android/libraries/network/NetworkModule.kt 0.00% 1 Missing ⚠️
...ibraries/wellknown/api/WellknownRetrieverResult.kt 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7139      +/-   ##
===========================================
+ Coverage    80.53%   80.57%   +0.03%     
===========================================
  Files         2705     2710       +5     
  Lines        78030    78114      +84     
  Branches     10532    10544      +12     
===========================================
+ Hits         62843    62938      +95     
+ Misses       11128    11110      -18     
- Partials      4059     4066       +7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmartinesp jmartinesp marked this pull request as ready for review July 2, 2026 11:43
@jmartinesp jmartinesp requested a review from a team as a code owner July 2, 2026 11:43
@jmartinesp jmartinesp requested review from ganfra and removed request for a team July 2, 2026 11:43

@bmarty bmarty left a comment

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.

Only small remarks, I let @ganfra do the proper review

Comment thread features/contentscanner/api/build.gradle.kts Outdated
Comment thread features/contentscanner/impl/build.gradle.kts Outdated
} else {
error("Either response or error must be provided")
}
}

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.

We could use mockwebserver but it's also OK.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I just tried using MockWebServer and while it works, it's also harder to set up and in some cases I end up having to use a mix of mocking (for spies) and the web server, so I'm not sure it's worth it. If @ganfra thinks we should change this too I can upload those changes.

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.

Ok for me like this

@ganfra ganfra left a comment

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.

Some remarks

@jmartinesp jmartinesp requested a review from ganfra July 7, 2026 07:15

@ganfra ganfra left a comment

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.

Thanks for the changes, LGTM now!

jmartinesp and others added 15 commits July 8, 2026 08:57
- Add `:features:contentscanner:api` module with the interface.
- Implement the concrete component using the Rust SDK in `:libraries:matrix:impl`.

This can be used to both set up the content scanner media fetching in the SDK Client and manually scanning media sources from the Android side
…api` module as a noop implementation

Use it as a placeholder for the code to instantiate a `RustContentScanner` with the fetched URL and set it as part of the SDK client.
…be reused for the non-session bound retriever.

Also add the new `content_scanner_url` field to it.

This will be used by the enterprise code to fetch the actual content scanner url.
This needed some tweaks to `RetrofitFactory`
Co-authored-by: Benoit Marty <benoitm@element.io>
Co-authored-by: Benoit Marty <benoitm@element.io>
… checking if we're running unit tests in `MediaSource.toRustMediaSource`
@jmartinesp jmartinesp force-pushed the feat/content-scanner-integration branch from 0271e0c to 2ada023 Compare July 8, 2026 06:57
@jmartinesp jmartinesp enabled auto-merge (squash) July 8, 2026 07:01
@jmartinesp jmartinesp disabled auto-merge July 8, 2026 07:09
@jmartinesp jmartinesp enabled auto-merge (squash) July 8, 2026 07:12
@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2026

Copy link
Copy Markdown

@jmartinesp jmartinesp merged commit 885e042 into develop Jul 8, 2026
31 of 32 checks passed
@jmartinesp jmartinesp deleted the feat/content-scanner-integration branch July 8, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR-Wip For anything that isn't ready to ship and will be enabled at a later date

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] Enable the content scanner in the SDK based on the well-known contents

3 participants