Skip to content

[WOOMOB-1438] Route media requests through WooMediaNetwork for app passwords#15534

Closed
hichamboushaba wants to merge 6 commits intotrunkfrom
issue/WOOMOB-1438-migrate-media-endpoints-to-app-passwords
Closed

[WOOMOB-1438] Route media requests through WooMediaNetwork for app passwords#15534
hichamboushaba wants to merge 6 commits intotrunkfrom
issue/WOOMOB-1438-migrate-media-endpoints-to-app-passwords

Conversation

@hichamboushaba
Copy link
Member

Description

Fixes WOOMOB-1438

The /media endpoints in FluxC still use old Java code that bypasses WooNetwork, so they weren't migrated to application passwords with the rest of the endpoints. This PR introduces WooMediaNetwork, a routing layer that:

  • Routes media upload, fetch, and cancel requests through application passwords for self-hosted (WPAPI) sites
  • For Jetpack (WPCOM_REST) sites, tries application passwords first and falls back to WPCom REST v2 if that fails, reporting the error via JetpackApplicationPasswordsErrorHandler
  • Simplifies MediaStore by replacing direct client references with delegation to WooMediaNetwork
  • Exposes statusCode and apiErrorCode on MediaError so the fallback logic can reconstruct proper WPAPINetworkErrors

Test Steps

  1. Connect a self-hosted WooCommerce site using application passwords
  2. Navigate to a product and upload a media image — verify it uploads successfully
  3. Fetch the media library — verify images load
  4. Cancel an in-progress upload — verify it cancels properly
  5. Connect a Jetpack site and repeat steps 2-4

Images/gif

N/A

  • I have considered if this change warrants release notes and have added them to RELEASE-NOTES.txt if necessary. Use the "[Internal]" label for non-user-facing changes.

@hichamboushaba hichamboushaba added type: task An internally driven task. feature: REST API Support connecting to sites using WordPress REST API. labels Mar 13, 2026
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is larger than 300 lines of changes. Please consider splitting it into smaller PRs for easier and faster reviews.
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 13, 2026

App Icon📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App NameWooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Build Number734
Version24.3-rc-3
Application IDcom.woocommerce.android.prealpha
Commit45c1505
Installation URL271658037j35o
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

private fun launchUpload(site: SiteModel, media: MediaModel) {
val uploadJob = coroutineEngine.launch(AppLog.T.MEDIA, this, "Uploading media") {
try {
when (site.origin) {

Check warning

Code scanning / Android Lint

Missing @IntDef in Switch Warning

Switch statement on an int with known associated constant missing case SiteModel.ORIGIN_UNKNOWN
Extract shared Jetpack guard, add GeneralSecurityException handling
matching WooNetwork, add logging for failed app-password requests,
and throw on unsupported site origins. Remove unused FluxCCrashLogger
from MediaStore. Expand test suite from 5 to 15 cases.
@hichamboushaba hichamboushaba force-pushed the issue/WOOMOB-1438-migrate-media-endpoints-to-app-passwords branch from 0fbc09e to 45c1505 Compare March 15, 2026 17:56
@hichamboushaba
Copy link
Member Author

Closing in favor of two smaller PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: REST API Support connecting to sites using WordPress REST API. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants