Fix. Integration. Amelia integration fixed: event_token added.#811
Open
alexander-b-clean wants to merge 10 commits into
Open
Fix. Integration. Amelia integration fixed: event_token added.#811alexander-b-clean wants to merge 10 commits into
event_token added.#811alexander-b-clean wants to merge 10 commits into
Conversation
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
# 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
event_token added.
Contributor
There was a problem hiding this comment.
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/wccalls and includeevent_tokenin the data returned for spam checking. - Add frontend XHR interception logic to inject
ct_bot_detector_event_tokenorct_no_cookie_hidden_fieldinto 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 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 on lines
+626
to
+631
| if (isNeedToAddCleantalkDataCheckJsonData) { | ||
| if (!( | ||
| +ctPublic.bot_detector_enabled && | ||
| apbctLocalStorage.get('bot_detector_event_token') | ||
| )) { | ||
| let noCookieData = getNoCookieData(); |
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.
https://app.doboard.comhttps://app.doboard.com/1/task/51225/1/task/51225