-
-
Notifications
You must be signed in to change notification settings - Fork 723
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
Add webhook triggered on Order Cycle Open #9687
Add webhook triggered on Order Cycle Open #9687
Commits on Mar 7, 2023
-
Add Faraday for making HTTP requests [add gem]
It's the most popular and flexible option, so should be able to cater for our future needs best.
Configuration menu - View commit details
-
Copy full SHA for 718ac0a - Browse repository at this point
Copy the full SHA 718ac0aView commit details -
This job is responsible for delivering a payload for one webhook event only. It allows the action to run asynchronously (and not slow down the calling process).
Configuration menu - View commit details
-
Copy full SHA for 9d19f37 - Browse repository at this point
Copy the full SHA 9d19f37View commit details -
And thus retry later. I tried to test that it actually retries, or ensuring the job remained in the queue to be retried, but couldn't get it to work.
Configuration menu - View commit details
-
Copy full SHA for 9741935 - Browse repository at this point
Copy the full SHA 9741935View commit details -
Prevent webhooks to private addresses (SSRF) [add gem]
Best reviewed with whitespace hidden. Unfortunately the spec isn't allowed in CI. But it worked on my environment, I promise. I chose `xit` so that it doesn't run unnecessarily. Perhaps we could use `pending` instead, which would execute, and notify us if it suddenly started working one day. But I doubt it.
Configuration menu - View commit details
-
Copy full SHA for de95465 - Browse repository at this point
Copy the full SHA de95465View commit details -
2. Add model WebhookEndpoint [migration]
This will store the URL for each user that wants a notification. We probably don't need URL validation (it's not done on Enterprise for example). It could be validated by browser input, and anyway will be validated if the webhook actually works or not. Inspired by Keygen: https://keygen.sh/blog/how-to-build-a-webhook-system-in-rails-using-sidekiq/
Configuration menu - View commit details
-
Copy full SHA for 85c98c6 - Browse repository at this point
Copy the full SHA 85c98c6View commit details -
User may have many WebhookEndpoints [migration]
Although we won't be allowing multiple in the this PR, we certainly plan to in the future. The migration helper add_reference couldn't handle the custom column name, so I had to put it together manually.
Configuration menu - View commit details
-
Copy full SHA for 778baba - Browse repository at this point
Copy the full SHA 778babaView commit details -
Configuration menu - View commit details
-
Copy full SHA for ba152f1 - Browse repository at this point
Copy the full SHA ba152f1View commit details -
Also send webhook payloads for distributor owners
But not supplier owners.
Configuration menu - View commit details
-
Copy full SHA for b91cabc - Browse repository at this point
Copy the full SHA b91cabcView commit details -
Configuration menu - View commit details
-
Copy full SHA for 739df4b - Browse repository at this point
Copy the full SHA 739df4bView commit details -
Prevent creating duplicate webhook notifications [migration]
Using the clever concurrency testing borrowed from SubscriptionPlacementJob, but I thought a shorter pause time (just 100ms) would be sufficient. I considered doing this with a new 'state' field (upcoming/open/close), but decided to keep it simple.
Configuration menu - View commit details
-
Copy full SHA for 3d81a6e - Browse repository at this point
Copy the full SHA 3d81a6eView commit details -
6. Add webhook endpoints to user developer settings screen
Allowing creation and deleting via the user association. It probably won't be much effort to allow editing and multiple records, but I cut it down to the minimum needed to avoid any further delays. I couldn't find a way to test a failure in the destroy method, but decided to keep the condition because I thought it was worth having.
Configuration menu - View commit details
-
Copy full SHA for 00a823b - Browse repository at this point
Copy the full SHA 00a823bView commit details -
Apply suggestions from code review
Co-authored-by: Maikel <[email protected]>
Configuration menu - View commit details
-
Copy full SHA for 9d5ca22 - Browse repository at this point
Copy the full SHA 9d5ca22View commit details
Commits on Mar 15, 2023
-
The best way to check if something changed or not, is with 'change' of course.
Configuration menu - View commit details
-
Copy full SHA for d59074d - Browse repository at this point
Copy the full SHA d59074dView commit details