Skip to content

fix: migrate NGA image hosts - #400

Merged
BugenZhao merged 2 commits into
mainfrom
agent/fix-nga-image-hosts
Aug 5, 2026
Merged

fix: migrate NGA image hosts#400
BugenZhao merged 2 commits into
mainfrom
agent/fix-nga-image-hosts

Conversation

@BugenZhao

Copy link
Copy Markdown
Owner

What changed

  • Add a centralized resource URL resolver that maps legacy NGA image hosts to img.nga.cn or img4.nga.cn based on the resource path.
  • Route post media, attachments, avatars, and forum icons through the resolver while keeping backend and internal-link preferences unchanged.
  • Update the forum icon service constant and network-backed fixtures to the canonical image hosts.
  • Preserve third-party absolute image URLs.

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 working img.<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 swiftformat
  • cargo test -p service (9 passed, 46 ignored external-state tests)
  • cargo clippy
  • make build (iPhone 17 Pro, iOS 26.2 Simulator; Build Succeeded)
  • Direct live probes for canonical attachment and forum icon paths returned HTTP 200

Fixes #399

@BugenZhao
BugenZhao marked this pull request as ready for review August 5, 2026 07:59
Copilot AI lite review requested due to automatic review settings August 5, 2026 07:59
@BugenZhao
BugenZhao merged commit ba4515e into main Aug 5, 2026
2 checks passed
@BugenZhao
BugenZhao deleted the agent/fix-nga-image-hosts branch August 5, 2026 07:59

Copilot AI left a comment

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.

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.attachmentURL to 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.

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.

不显示图片

2 participants