Add support for webhook-based notifications #1181
No reviewers
Labels
No Label
dependencies
duplicate
help wanted
invalid
kind/bug
kind/feature
needs reproduction
question
security
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/vikunja#1181
Loading…
Reference in New Issue
No description provided.
Delete Branch "rounakdatta/api:webhook-notification"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
This pull request introduces webhook as a type of notification. The enablement of the webhook feature and the endpoint URL can be controlled via config.
Checklist
mage do-the-swag
)config.yml.saml
and runningmage generate-docs
)WIP: webhook-notificationto WIP: Add support for webhook-based notificationsNice!
I know this is still wip, but here's a few notes of mine:
Thanks @konrad ,
Well, keeping the endpoint URL user/list/namespace specific is turning out to be non-trivial 😅, especially since it will require migrations on multiple tables including
user
. As you suggested, we should probably do it in a follow-up PR.WIP: Add support for webhook-based notificationsto Add support for webhook-based notificationsLooks pretty good already!
Please fix the lint errors and add a test for the feature.
@ -0,0 +7,4 @@
)
// DoPost accepts a stringified body makes a post request
func DoPost(url string, body string, headers map[string]string) (resp *http.Response, err error) {
I wonder if this could be combined with the
doPost
helper from the migratiors?@ -59,2 +60,4 @@
}
if config.WebhookNotificationsEnabled.GetBool() {
err = notifyWebhook(notifiable, notification)
Even though notifications are almost always sent as a result of some async event, I think this should be done async explicitely. I'd publish a
WebhookEvent
or similar and then notify the url in the listener to that event.The check whether webhook notifications are enabled or not could then happen while registering the listener for that event (= only register the listener if webhook notifications are enabled).
@ -0,0 +25,4 @@
)
const (
webhookNotificationSignatureHeader = "x-vikunja-signature"
Please use
X-Vikunja-Signature
(capitalized)@ -0,0 +50,4 @@
return err
}
defer resp.Body.Close()
// TODO: Have response-code based checks
What should those checks look like?
Follow-Up PR is fine by me. Keeps this one small and easy to review :)
I'm curious, why would that require a migration on the user table?
Closing this due to inactivity. Please ping if you want to pick it up again.
Pull request closed