Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TECH-232: Add support for VATSIM.net Webhooks #3948

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CalumTowers
Copy link
Contributor

Docs: https://vatsim.dev/services/webhooks.

If testing locally on sync, be sure to remove ->afterResponse().

Copy link

linear bot commented Jan 9, 2025

foreach (request()->json('actions') as $action) {
$class = config("services.vatsim-net.webhook.jobs.{$action['action']}");
if ($class && class_exists($class)) {
dispatch(new $class(request()->json('resource'), $action))->afterResponse();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for ease of running sync locally here can we just drop ->afterResponse() entirely. Dispatching queue jobs should be fast anyway and I don't think the system sending the webhooks is gonna mind too much

Suggested change
dispatch(new $class(request()->json('resource'), $action))->afterResponse();
dispatch(new $class(request()->json('resource'), $action));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

->defer() actually handles the sync driver proper and waits until after the response is returned too. So probably best of both worlds to do that.

}

foreach (request()->json('actions') as $action) {
$class = config("services.vatsim-net.webhook.jobs.{$action['action']}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is very laravel, but personally I'd have an explicit switch here with some logging for actions we don't understand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout.

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.

2 participants