Skip to content

feat(linkcheck): replace a link that moved by its new address in the texts - #2834

Merged
lbesson merged 1 commit into
masterfrom
feat/linkcheck-replace-url
Dec 3, 2026
Merged

lbesson merged 1 commit into
masterfrom
feat/linkcheck-replace-url

Conversation

@lbesson

@lbesson lbesson commented Dec 3, 2026

Copy link
Copy Markdown
Member

Topic 2 of the moderation of the external links: a moderator replaces a link that moved by the address it leads to now, in every text.

API

POST /documents/external-links/replace {url, new_url} (moderators), for a link the list says replaceable: moved, ok with a final URL (http → https…), or redirected to another site and reviewed genuine.

Before anything is written, the link is fetched again: it is replaced only if it is still redirected permanently (301 or 308 at every step) to new_url, a page that answers, and not a home or login page. A temporary redirection (302, 303, 307) is refused, as an address that may change again.

Then each collaborative document linking it gets a new version by the moderator. A text that writes the address otherwise (escaped…) is left as it is and listed in the answer, to change by hand. The new address is recorded as checked, so the link keeps its credit (rel).

GET /documents/external-links: replaceable on each link.

Tests

tests/linkcheck/test_replace.py, tests/views/test_external_links_replace.py (11): permanent vs temporary redirections, a page gone or sent home, versions and texts, escaped addresses left, moderators only; contract tests + route inventory.

Locally the linkcheck, external links, markdown and contract tests pass (541 + 11). In a full run with 4 workers some search tests failed on Elasticsearch timeouts; test_waypoint.py and test_xreport.py pass on their own, on master and on this branch alike.

UI: c2corg/c2c_ui PR to follow, after this one is deployed.

🤖 Generated with Claude Code

…texts

POST /documents/external-links/replace {url, new_url} (moderators): for a
link redirected (moved, ok after http -> https..., or another site reviewed
genuine), the link is fetched again first and replaced only when still
redirected permanently (301/308 at every step) to new_url, a page that
answers (not a home or login page). Each collaborative document linking it
gets a new version by the moderator; a text whose address is written
otherwise (escaped...) is left as it was and listed in the answer. The new
address is recorded as checked, so the link keeps its credit.

The list says which links are replaceable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1dc4399-b87a-4e09-b445-4300191250f7
Commits

Reviewing files that changed from the base of the PR and between 4022a9d and 81407f9.

Files selected for processing: 9

  • c2corg_api/linkcheck/fetch.py
  • c2corg_api/linkcheck/replace.py
  • c2corg_api/tests/contract/routes.txt
  • c2corg_api/tests/contract/test_document_action_writes.py
  • c2corg_api/tests/linkcheck/test_replace.py
  • c2corg_api/tests/views/test_external_links_replace.py
  • c2corg_api/views/external_links.py
  • c2corg_api/views/markdown.py
  • c2corg_api/web/document_actions.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 73 complexity · 0 duplication

Metric Results
Complexity 73
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@lbesson
lbesson merged commit 18b4e82 into master Dec 3, 2026
8 checks passed
@lbesson
lbesson deleted the feat/linkcheck-replace-url branch December 3, 2026 10:57
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.

1 participant