summaryrefslogtreecommitdiff
path: root/services/worker/internal/webhook/webhook.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-07 01:44:12 -0800
committerFuwn <[email protected]>2026-02-07 01:44:12 -0800
commit504a0c1bed5b2086fec1e3b89027d328f9c09604 (patch)
tree3e92560239227426daef6a7d549bd7ea0ca14805 /services/worker/internal/webhook/webhook.go
parentfeat: asa.news RSS reader with developer tier, REST API, and webhooks (diff)
downloadasa.news-504a0c1bed5b2086fec1e3b89027d328f9c09604.tar.xz
asa.news-504a0c1bed5b2086fec1e3b89027d328f9c09604.zip
style: format Go worker with iku
Diffstat (limited to 'services/worker/internal/webhook/webhook.go')
-rw-r--r--services/worker/internal/webhook/webhook.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/services/worker/internal/webhook/webhook.go b/services/worker/internal/webhook/webhook.go
index c812820..cf063b9 100644
--- a/services/worker/internal/webhook/webhook.go
+++ b/services/worker/internal/webhook/webhook.go
@@ -129,7 +129,6 @@ func (webhookDispatcher *Dispatcher) findWebhookSubscribers(
AND up.webhook_enabled = true
AND up.webhook_url IS NOT NULL
`
-
rows, queryError := webhookDispatcher.databaseConnectionPool.Query(
queryContext,
subscriberQuery,
@@ -194,6 +193,7 @@ func (webhookDispatcher *Dispatcher) deliverWebhook(
}
retryDelays := []time.Duration{0, 1 * time.Second, 4 * time.Second, 16 * time.Second}
+
var lastError error
for attemptIndex, delay := range retryDelays {
@@ -240,7 +240,6 @@ func (webhookDispatcher *Dispatcher) deliverWebhook(
"user_identifier", subscriber.UserIdentifier,
"error", lastError,
)
-
webhookDispatcher.incrementConsecutiveFailures(deliveryContext, subscriber.UserIdentifier)
}
@@ -265,8 +264,11 @@ func (webhookDispatcher *Dispatcher) sendWebhookRequest(
if subscriber.WebhookSecret != nil && *subscriber.WebhookSecret != "" {
mac := hmac.New(sha256.New, []byte(*subscriber.WebhookSecret))
+
mac.Write(payloadBytes)
+
signature := hex.EncodeToString(mac.Sum(nil))
+
request.Header.Set("X-Asa-Signature-256", "sha256="+signature)
}
@@ -309,7 +311,6 @@ func (webhookDispatcher *Dispatcher) incrementConsecutiveFailures(
userIdentifier string,
) {
maximumConsecutiveFailures := 10
-
_, updateError := webhookDispatcher.databaseConnectionPool.Exec(
updateContext,
`UPDATE user_profiles