From 85444f5a479529a3a3cff645f1e287d813b57db8 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 3 Sep 2024 16:28:46 +0200 Subject: [PATCH] :bug: Fix incorrect params handling on webhook processing task --- CHANGES.md | 6 +++++ backend/src/app/loggers/audit.clj | 2 ++ backend/src/app/loggers/webhooks.clj | 25 ++++++++----------- .../backend_tests/loggers_webhooks_test.clj | 14 +++++------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5b6141608..16a0868f0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 2.1.5 + +### :bug: Bugs fixed + +- Fix broken webhooks [Taiga #8370](https://tree.taiga.io/project/penpot/issue/8370) + ## 2.1.4 ### :bug: Bugs fixed diff --git a/backend/src/app/loggers/audit.clj b/backend/src/app/loggers/audit.clj index c0ca61da9..6b1e7ea28 100644 --- a/backend/src/app/loggers/audit.clj +++ b/backend/src/app/loggers/audit.clj @@ -263,6 +263,8 @@ (assoc ::wrk/dedupe dedupe?) (assoc ::wrk/label label) (assoc ::wrk/params (-> params + (dissoc :source) + (dissoc :context) (dissoc :ip-addr) (dissoc :type))))))) params)) diff --git a/backend/src/app/loggers/webhooks.clj b/backend/src/app/loggers/webhooks.clj index cd6385429..371b627bb 100644 --- a/backend/src/app/loggers/webhooks.clj +++ b/backend/src/app/loggers/webhooks.clj @@ -66,21 +66,18 @@ (defmethod ig/init-key ::process-event-handler [_ cfg] (fn [{:keys [props] :as task}] - (let [event (:event props)] - (l/dbg :hint "process webhook event" :name (:name event)) - - (when-let [items (lookup-webhooks cfg event)] - (l/trc :hint "webhooks found for event" :total (count items)) - - (db/tx-run! cfg (fn [cfg] - (doseq [item items] - (wrk/submit! (-> cfg - (assoc ::wrk/task :run-webhook) - (assoc ::wrk/queue :webhooks) - (assoc ::wrk/max-retries 3) - (assoc ::wrk/params {:event event - :config item})))))))))) + (l/dbg :hint "process webhook event" :name (:name props)) + (when-let [items (lookup-webhooks cfg props)] + (l/trc :hint "webhooks found for event" :total (count items)) + (db/tx-run! cfg (fn [cfg] + (doseq [item items] + (wrk/submit! (-> cfg + (assoc ::wrk/task :run-webhook) + (assoc ::wrk/queue :webhooks) + (assoc ::wrk/max-retries 3) + (assoc ::wrk/params {:event props + :config item}))))))))) ;; --- RUN (declare interpret-exception) diff --git a/backend/test/backend_tests/loggers_webhooks_test.clj b/backend/test/backend_tests/loggers_webhooks_test.clj index d0a8e7475..c34df7154 100644 --- a/backend/test/backend_tests/loggers_webhooks_test.clj +++ b/backend/test/backend_tests/loggers_webhooks_test.clj @@ -21,10 +21,9 @@ (with-mocks [submit-mock {:target 'app.worker/submit! :return nil}] (let [prof (th/create-profile* 1 {:is-active true}) res (th/run-task! :process-webhook-event - {:event - {:type "command" - :name "create-project" - :props {:team-id (:default-team-id prof)}}})] + {:type "command" + :name "create-project" + :props {:team-id (:default-team-id prof)}})] (t/is (= 0 (:call-count @submit-mock))) (t/is (nil? res))))) @@ -34,10 +33,9 @@ (let [prof (th/create-profile* 1 {:is-active true}) whk (th/create-webhook* {:team-id (:default-team-id prof)}) res (th/run-task! :process-webhook-event - {:event - {:type "command" - :name "create-project" - :props {:team-id (:default-team-id prof)}}})] + {:type "command" + :name "create-project" + :props {:team-id (:default-team-id prof)}})] (t/is (= 1 (:call-count @submit-mock))) (t/is (nil? res)))))