T427936: Support hCaptcha in DiscussionTools API edits - #6002
Open
kostajh wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for handling hCaptcha challenges when creating new talk page topics or replies via the discussiontoolsedit API, integrating the server-provided hCaptcha site key and “always-challenge” behavior into the existing edit flow.
Changes:
- Detect hCaptcha challenges from
discussiontoolseditresponses (including server site key + force-show flag) and surface as a typedTalkPageError. - Present
WMFHCaptchaViewControllerwith a site key override, then retry the edit withcaptchaword(andwgConfirmEditForceShowCaptchawhen required). - Append the localized “protected by hCaptcha” fine print (fetched via
MessagesDataController) to topic/reply compose UI, and add unit tests for response evaluation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| WikipediaUnitTests/Code/TalkPageFetcherTests.swift | Adds unit tests for TalkPageFetcher.evaluateResponse, including hCaptcha challenge parsing. |
| Wikipedia/Code/WMFHCaptchaViewController.swift | Adds siteKeyOverride support so the captcha token is solved against a server-specified site key. |
| Wikipedia/Code/TalkPageViewModel.swift | Threads optional hCaptcha token + force-show flag through view model APIs to the data controller. |
| Wikipedia/Code/TalkPageViewController.swift | Presents hCaptcha challenge on failure, then retries posting topic/reply with the solved token. |
| Wikipedia/Code/TalkPageTopicComposeViewController.swift | Fetches and appends localized hCaptcha fine print to the compose screen’s fine print text. |
| Wikipedia/Code/TalkPageReplyComposeContentView.swift | Fetches and appends localized hCaptcha fine print to the reply compose fine print text. |
| Wikipedia/Code/TalkPageFetcher.swift | Adds captcha request parameters + parses hCaptcha challenges and validates “success” includes newrevid. |
| Wikipedia/Code/TalkPageDataController.swift | Adds hCaptcha error type + threads captcha token/force flag to the fetcher. |
| Wikipedia.xcodeproj/project.pbxproj | Adds the new unit test file to the unit test target sources. |
Comment on lines
+1249
to
+1260
| hcaptchaVC.successAction = { token in | ||
| hcaptchaVC.dismiss(animated: true) { | ||
| onSuccess(token) | ||
| } | ||
| } | ||
|
|
||
| hcaptchaVC.errorAction = { error in | ||
| hcaptchaVC.dismiss(animated: true) { | ||
| WMFToastManager.sharedInstance.showErrorAlert(error, sticky: true, dismissPreviousToasts: true) | ||
| onError() | ||
| } | ||
| } |
kostajh
force-pushed
the
T427936-hcaptcha-discussiontools
branch
from
July 14, 2026 07:43
269c92f to
94ebd8c
Compare
Why: - discussiontoolsedit can reject talk replies and new topics pending an hCaptcha challenge that the app does not handle What: - Detect the challenge in TalkPageFetcher, surfacing the sitekey and always-challenge flag - Present the existing WMFHCaptchaViewController and resubmit the edit with the token as `captchaword`, plus wgConfirmEditForceShowCaptcha when an interactive always-challenge is required - Solve a normal challenge against the app's own iOS editing sitekey from remote config (iosv1.hCaptcha.editApiKey), which the server also accepts as a valid edit key; use the server-returned key only for a forced always-challenge - Append the localized hcaptcha-privacy-policy notice to the Terms of Use and license fine print shown before Publish, so the ToS/privacy disclosure appears in advance of submitting (matching the Android app); fetch best-effort per edit-wiki language - Weak-capture the captcha view controller in its success and error closures to avoid a retain cycle Assisted-by: Claude Opus 4.8
kostajh
force-pushed
the
T427936-hcaptcha-discussiontools
branch
from
July 14, 2026 10:37
94ebd8c to
72075a2
Compare
tonisevener
self-requested a review
July 21, 2026 14:30
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.
Phabricator: https://phabricator.wikimedia.org/T427936
Why:
What:
captchaword, plus wgConfirmEditForceShowCaptcha when an interactive always-challenge is requiredAssisted-by: Claude Opus 4.8