Skip to content

T427936: Support hCaptcha in DiscussionTools API edits - #6002

Open
kostajh wants to merge 1 commit into
wikimedia:mainfrom
kostajh:T427936-hcaptcha-discussiontools
Open

T427936: Support hCaptcha in DiscussionTools API edits#6002
kostajh wants to merge 1 commit into
wikimedia:mainfrom
kostajh:T427936-hcaptcha-discussiontools

Conversation

@kostajh

@kostajh kostajh commented Jul 6, 2026

Copy link
Copy Markdown

Phabricator: https://phabricator.wikimedia.org/T427936

Why:

  • Talk-page replies and new topics posted via discussiontoolsedit should support hCaptcha.

What:

  • Detect the challenge in TalkPageFetcher, surfacing the server suggested sitekey and always-challenge flag
  • present the existing WMFHCaptchaViewController (adding siteKeyOverride so the token is solved against the key the server verifies)
  • resubmit the edit with the token as captchaword, plus wgConfirmEditForceShowCaptcha when an interactive always-challenge is required

Assisted-by: Claude Opus 4.8

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

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 discussiontoolsedit responses (including server site key + force-show flag) and surface as a typed TalkPageError.
  • Present WMFHCaptchaViewController with a site key override, then retry the edit with captchaword (and wgConfirmEditForceShowCaptcha when 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
kostajh force-pushed the T427936-hcaptcha-discussiontools branch from 269c92f to 94ebd8c Compare July 14, 2026 07:43
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
kostajh force-pushed the T427936-hcaptcha-discussiontools branch from 94ebd8c to 72075a2 Compare July 14, 2026 10:37
@tonisevener
tonisevener self-requested a review July 21, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants