🔄 Refactor: VATSIM.net Webhook Processing (Improved Observability & Safety)#4545
Open
MrAdder wants to merge 14 commits intoVATSIM-UK:mainfrom
Open
🔄 Refactor: VATSIM.net Webhook Processing (Improved Observability & Safety)#4545MrAdder wants to merge 14 commits intoVATSIM-UK:mainfrom
MrAdder wants to merge 14 commits intoVATSIM-UK:mainfrom
Conversation
5 tasks
Contributor
Author
|
^ The Failing check is a Github issue not myself |
Contributor
Author
|
@AxonC or @kristiankunc I have tested this as best as possible however I do not have Webhook permissions with VatsimDev if one of you could test this that would be great. |
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the VATSIM.net webhook processing pipeline to make action handling deterministic (timestamp ordering + chained dispatch), improve observability, and reduce duplicated delta parsing logic across webhook jobs.
Changes:
- Refactored
ProcessVatsimNetWebhookto sort actions deterministically, resolve jobs via a map, and dispatch viaBus::chain()with structured logging. - Introduced
InteractsWithMemberDeltastrait and updatedMemberCreatedAction/MemberChangedActionto use cached delta parsing helpers. - Added a feature test asserting unknown webhook actions return
400 Bad Request.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php |
Centralizes action→job resolution, sorts actions by timestamp, chains jobs, and improves logging/empty-payload handling. |
app/Jobs/ExternalServices/VatsimNet/Webhooks/Concerns/InteractsWithMemberDeltas.php |
Adds reusable cached delta parsing + changed-field map helpers. |
app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberCreatedAction.php |
Simplifies creation handling using the delta trait and adds debug logging. |
app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberChangedAction.php |
Refactors update handling into focused methods using the delta trait and adds debug logging. |
tests/Feature/External/Webhooks/WebhooksTest.php |
Adds coverage for unknown webhook action returning 400. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberChangedAction.php
Outdated
Show resolved
Hide resolved
app/Jobs/ExternalServices/VatsimNet/Webhooks/MemberCreatedAction.php
Outdated
Show resolved
Hide resolved
app/Http/Controllers/External/VatsimNet/ProcessVatsimNetWebhook.php
Outdated
Show resolved
Hide resolved
8 tasks
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.
Refs #4550
This PR further refactors the VATSIM.net webhook pipeline to improve determinism, performance, logging, and internal structure while preserving existing behaviour.
🚀 Controller Improvements (
ProcessVatsimNetWebhook)✅ Deterministic Ordering
collect()->sortBy('timestamp')->values()to guarantee correct execution order.Bus::chain()to prevent race conditions between actions.🗺️ Centralised Action Resolution
ACTION_JOB_MAPconstant to replace theswitchstatement.createActionJob()resolver method.400 Bad RequestThis makes the system easier to extend with additional webhook actions.
📊 Improved Logging & Observability
resourceactions.lengthactions.typespreparation_ms) for lightweight performance insight.🧯 Graceful Empty Payload Handling
200 OK🔐 Security
validateAuth()now strictly typed (: void)🧩 New Trait:
InteractsWithMemberDeltasIntroduced reusable delta handling logic:
Features
getDeltaAfter(field)helperchangedFields()keyed map offield => afterThis removes duplicated delta parsing logic and reduces repeated collection operations.
👤
MemberChangedActionRefactorStructural Changes
InteractsWithMemberDeltastraitACCOUNT_FIELDSconstantprocessAccountChanges()processRatingChanges()processStateChange()Behaviour Improvements
Benefits
👶
MemberCreatedActionRefactorupdateOrCreatelogicresourceandaccount_idImproves readability and consistency with the update handler.
🧪 Test Coverage Improvements
Added:
test_unknown_action_returns_bad_request()to ensure invalid webhook actions return400.Existing tests validate:
🧼 Overall Outcome
This refactor delivers:
The webhook pipeline is now more maintainable, extensible, and production-observable while preserving existing functionality.