fix: migrate NGA image hosts - #400
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores broken NGA-hosted images by introducing a centralized URL resolver on the Swift side and updating hardcoded/test fixture image hostnames (Rust + Swift) to the canonical img.nga.cn / img4.nga.cn domains, while preserving non-NGA third-party absolute URLs.
Changes:
- Added
URLs.resourceURL/URLs.attachmentURLto rewrite legacy NGA image domains to canonical hosts (and force HTTPS), based on resource path. - Routed avatars, forum icons, and attachment/media URL construction through the resolver in Swift UI/content rendering paths.
- Updated Rust forum icon base constant and updated network-backed fixture URLs to use canonical image hosts.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| logic/text/src/content.rs | Updates a parsing test fixture image URL to the canonical host. |
| logic/service/src/post.rs | Updates a network-backed test probe image URL to the canonical host. |
| logic/service/src/constants.rs | Switches forum icon base URL to https://img4.nga.cn/.... |
| app/Shared/Views/UserView.swift | Routes avatar loading through URLs.resourceURL. |
| app/Shared/Views/UserMenuView.swift | Routes menu avatar loading through URLs.resourceURL and keys view identity off the resolved URL. |
| app/Shared/Views/TopicListView.swift | Updates preview forum icon URL to canonical host. |
| app/Shared/Views/PostContentView.swift | Updates preview image URL to canonical host. |
| app/Shared/Views/ForumIconView.swift | Routes forum icon loading through URLs.resourceURL and keys identity off the resolved URL. |
| app/Shared/Views/AttachmentsView.swift | Uses URLs.attachmentURL for attachment navigation/viewing. |
| app/Shared/Utilities/URLs.swift | Adds centralized legacy-host migration logic and updates attachment base host. |
| app/Shared/Utilities/ContentCombiner.swift | Uses URLs.attachmentURL when constructing media/attachment URLs from parsed content. |
| app/Shared/Protos/Extensions.swift | Updates user avatar fixture URL to canonical host. |
| app/Shared/Models/AttachmentsModel.swift | Resolves attachment URLs via URLs.attachmentURL and matches against preview URLs by equality. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
img.nga.cnorimg4.nga.cnbased on the resource path.Root cause
NGA stopped resolving
img.nga.178.com, while MNGA still used it as the fixed attachment base. The alternate backend candidates do not expose equivalent workingimg.<backend>endpoints, so image resources require canonical asset hosts independent of the selected API backend.User impact
Restores NGA-hosted images, attachment previews, avatars, media links, and forum icons. Historical absolute URLs using retired NGA image domains are migrated at load time.
Validation
make swiftformatcargo test -p service(9 passed, 46 ignored external-state tests)cargo clippymake build(iPhone 17 Pro, iOS 26.2 Simulator; Build Succeeded)Fixes #399