From d80a24b1e37d4ff35d0f09d767b4db267dbdc915 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 15 Dec 2022 12:01:47 +0100 Subject: [PATCH] :sparkles: Add font events to webhooks --- backend/src/app/loggers/webhooks.clj | 1 - backend/src/app/rpc/mutations/fonts.clj | 46 +++++++++++++++---------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/backend/src/app/loggers/webhooks.clj b/backend/src/app/loggers/webhooks.clj index 55a034baa..abd902aec 100644 --- a/backend/src/app/loggers/webhooks.clj +++ b/backend/src/app/loggers/webhooks.clj @@ -62,7 +62,6 @@ :name (:name event)) (when-let [items (lookup-webhooks cfg event)] - ;; (app.common.pprint/pprint items) (l/trace :hint "webhooks found for event" :total (count items)) (db/with-atomic [conn pool] diff --git a/backend/src/app/rpc/mutations/fonts.clj b/backend/src/app/rpc/mutations/fonts.clj index 716147a39..1f00de84c 100644 --- a/backend/src/app/rpc/mutations/fonts.clj +++ b/backend/src/app/rpc/mutations/fonts.clj @@ -110,12 +110,12 @@ ] (->> (generate-fonts data) - (p/map validate-data) + (p/fmap validate-data) (p/mcat executor persist-fonts) - (p/map executor insert-into-db) - (p/map (fn [result] - (let [params (update params :data (comp vec keys))] - (rph/with-meta result {::audit/replace-props params}))))))) + (p/fmap executor insert-into-db) + (p/fmap (fn [result] + (let [params (update params :data (comp vec keys))] + (rph/with-meta result {::audit/replace-props params}))))))) ;; --- UPDATE FONT FAMILY @@ -128,10 +128,15 @@ [{:keys [pool] :as cfg} {:keys [team-id profile-id id name] :as params}] (db/with-atomic [conn pool] (teams/check-edition-permissions! conn profile-id team-id) - (db/update! conn :team-font-variant - {:font-family name} - {:font-id id - :team-id team-id}))) + (rph/with-meta + (db/update! conn :team-font-variant + {:font-family name} + {:font-id id + :team-id team-id}) + {::audit/replace-props {:id id + :name name + :team-id team-id + :profile-id profile-id}}))) ;; --- DELETE FONT @@ -144,10 +149,14 @@ [{:keys [pool] :as cfg} {:keys [id team-id profile-id] :as params}] (db/with-atomic [conn pool] (teams/check-edition-permissions! conn profile-id team-id) - (db/update! conn :team-font-variant - {:deleted-at (dt/now)} - {:font-id id :team-id team-id}) - nil)) + (let [font (db/update! conn :team-font-variant + {:deleted-at (dt/now)} + {:font-id id :team-id team-id})] + (rph/with-meta (rph/wrap) + {::audit/props {:id id + :team-id team-id + :name (:font-family font) + :profile-id profile-id}})))) ;; --- DELETE FONT VARIANT @@ -160,8 +169,9 @@ [{:keys [pool] :as cfg} {:keys [id team-id profile-id] :as params}] (db/with-atomic [conn pool] (teams/check-edition-permissions! conn profile-id team-id) - - (db/update! conn :team-font-variant - {:deleted-at (dt/now)} - {:id id :team-id team-id}) - nil)) + (let [variant (db/update! conn :team-font-variant + {:deleted-at (dt/now)} + {:id id :team-id team-id})] + (rph/with-meta (rph/wrap) + {::audit/props {:font-family (:font-family variant) + :font-id (:font-id variant)}}))))