Skip to content

Fix. Integration. Amelia integration fixed: event_token added.#811

Open
alexander-b-clean wants to merge 10 commits into
devfrom
amelia-event-token.ab
Open

Fix. Integration. Amelia integration fixed: event_token added.#811
alexander-b-clean wants to merge 10 commits into
devfrom
amelia-event-token.ab

Conversation

@alexander-b-clean

Copy link
Copy Markdown
Contributor

@alexander-b-clean alexander-b-clean changed the base branch from master to dev June 15, 2026 16:14
@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 26.57%. Comparing base (6695732) to head (ee3adca).

Files with missing lines Patch % Lines
lib/Cleantalk/Antispam/Integrations/Amelia.php 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##                dev     #811   +/-   ##
=========================================
  Coverage     26.57%   26.57%           
- Complexity     5676     5678    +2     
=========================================
  Files           269      269           
  Lines         24258    24263    +5     
=========================================
+ Hits           6446     6449    +3     
- Misses        17812    17814    +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

datorik and others added 7 commits June 16, 2026 13:46
# Conflicts:
#	js/apbct-public-bundle.min.js
#	js/apbct-public-bundle_ext-protection.min.js
#	js/apbct-public-bundle_ext-protection_gathering.min.js
#	js/apbct-public-bundle_full-protection.min.js
#	js/apbct-public-bundle_full-protection_gathering.min.js
#	js/apbct-public-bundle_gathering.min.js
#	js/apbct-public-bundle_int-protection.min.js
#	js/apbct-public-bundle_int-protection_gathering.min.js
@Glomberg Glomberg changed the title Code. Amelia add event_token Fix. Integration. Amelia integration fixed: event_token added. Jun 24, 2026
@Glomberg Glomberg requested a review from Copilot June 24, 2026 13:01

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 updates the Amelia integration to propagate and consume CleanTalk bot-detector context (event token / no-cookie data) for Amelia AJAX requests, including an additional Amelia API route.

Changes:

  • Extend the Amelia hook integration to accept /payment/wc calls and include event_token in the data returned for spam checking.
  • Add frontend XHR interception logic to inject ct_bot_detector_event_token or ct_no_cookie_hidden_field into Amelia JSON payloads.
  • Update and expand PHPUnit coverage for the Amelia integration’s returned checking data (including event_token).

Reviewed changes

Copilot reviewed 11 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/Antispam/IntegrationsByHook/TestAmelia.php Updates assertions to include event_token and adds a test covering token extraction from JSON payload.
lib/Cleantalk/Antispam/Integrations/Amelia.php Accepts an additional Amelia endpoint and returns event_token; triggers no-cookie data extraction when present.
js/src/public-1-main.js Injects bot-detector token or no-cookie data into Amelia JSON XHR bodies (detected via action=wpamelia_api).
js/prebuild/apbct-public-bundle.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_int-protection.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_int-protection_gathering.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_gathering.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_full-protection.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_full-protection_gathering.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_ext-protection.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/prebuild/apbct-public-bundle_ext-protection_gathering.js Prebuilt bundle updated to include the new Amelia XHR JSON injection logic.
js/apbct-public-bundle.min.js Minified bundle updated to include the new Amelia XHR JSON injection logic.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +42 to +45
$event_token = ! empty($payload['ct_bot_detector_event_token'])
? (string) $payload['ct_bot_detector_event_token']
: Post::getString('ct_bot_detector_event_token');

}

return true;
return $call === '/bookings' || $call === '/payment/wc';
Comment thread js/src/public-1-main.js
Comment on lines +534 to +540
XMLHttpRequest.prototype.open = function(method, url, ...rest) {
try {
this._apbctAjaxCallUrl = typeof url === 'string' ? url : '';
} catch (e) {
// ignore
}
return originalOpen.call(this, method, url, ...rest);
Comment thread js/src/public-1-main.js
Comment on lines +626 to +631
if (isNeedToAddCleantalkDataCheckJsonData) {
if (!(
+ctPublic.bot_detector_enabled &&
apbctLocalStorage.get('bot_detector_event_token')
)) {
let noCookieData = getNoCookieData();
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.

4 participants