From fa7cf70ceea4447fa569c6e6f06a025fa03e52e2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 16 Dec 2022 09:26:21 +0100 Subject: [PATCH] :sparkles: Add import, export and management events to webhooks --- backend/src/app/rpc/commands/binfile.clj | 19 ++++++++++++------- backend/src/app/rpc/commands/comments.clj | 3 +-- backend/src/app/rpc/commands/management.clj | 16 +++++++++++----- 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 0daeb8190..c9cf634b4 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -15,6 +15,7 @@ [app.common.uuid :as uuid] [app.config :as cf] [app.db :as db] + [app.loggers.webhooks :as-alias webhooks] [app.media :as media] [app.rpc.commands.files :as files] [app.rpc.doc :as-alias doc] @@ -840,10 +841,10 @@ (defn import! [{:keys [::input] :as cfg}] (let [id (uuid/next) - ts (dt/now) + tp (dt/tpoint) cs (volatile! nil)] + (l/info :hint "import: started" :import-id id) (try - (l/info :hint "start importation" :import-id id) (binding [*position* (atom 0)] (with-open [^AutoCloseable input (io/input-stream input)] (read-import! (assoc cfg ::input input)))) @@ -853,10 +854,12 @@ (throw cause)) (finally - (l/info :hint "importation finished" :import-id id - :elapsed (str (inst-ms (dt/diff ts (dt/now))) "ms") + (l/info :hint "import: terminated" + :import-id id + :elapsed (dt/format-duration (tp)) :error? (some? @cs) - :cause @cs))))) + :cause @cs + ))))) ;; --- Command: export-binfile @@ -870,7 +873,8 @@ (sv/defmethod ::export-binfile "Export a penpot file in a binary format." - {::doc/added "1.15"} + {::doc/added "1.15" + ::webhooks/event? true} [{:keys [pool] :as cfg} {:keys [profile-id file-id include-libraries? embed-assets?] :as params}] (files/check-read-permissions! pool profile-id file-id) (let [body (reify yrs/StreamableResponseBody @@ -890,7 +894,8 @@ (sv/defmethod ::import-binfile "Import a penpot file in a binary format." - {::doc/added "1.15"} + {::doc/added "1.15" + ::webhooks/event? true} [{:keys [pool] :as cfg} {:keys [profile-id project-id file] :as params}] (db/with-atomic [conn pool] (projects/check-read-permissions! conn profile-id project-id) diff --git a/backend/src/app/rpc/commands/comments.clj b/backend/src/app/rpc/commands/comments.clj index 8d1162cad..9e45f417d 100644 --- a/backend/src/app/rpc/commands/comments.clj +++ b/backend/src/app/rpc/commands/comments.clj @@ -496,8 +496,7 @@ (s/keys :req-un [::profile-id ::id])) (sv/defmethod ::delete-comment - {::doc/added "1.15" - ::webhooks/event? true} + {::doc/added "1.15"} [{:keys [pool] :as cfg} {:keys [profile-id id] :as params}] (db/with-atomic [conn pool] (let [comment (db/get-by-id conn :comment id {:for-update true})] diff --git a/backend/src/app/rpc/commands/management.clj b/backend/src/app/rpc/commands/management.clj index d647c90c4..ad2fc51b1 100644 --- a/backend/src/app/rpc/commands/management.clj +++ b/backend/src/app/rpc/commands/management.clj @@ -13,6 +13,7 @@ [app.common.spec :as us] [app.common.uuid :as uuid] [app.db :as db] + [app.loggers.webhooks :as-alias webhooks] [app.rpc.commands.binfile :as binfile] [app.rpc.commands.files :as files] [app.rpc.commands.teams :as teams :refer [create-project-role create-project]] @@ -42,7 +43,8 @@ (sv/defmethod ::duplicate-file "Duplicate a single file in the same team." - {::doc/added "1.16"} + {::doc/added "1.16" + ::webhooks/event? true} [{:keys [pool] :as cfg} params] (db/with-atomic [conn pool] (duplicate-file conn params))) @@ -215,7 +217,8 @@ (sv/defmethod ::duplicate-project "Duplicate an entire project with all the files" - {::doc/added "1.16"} + {::doc/added "1.16" + ::webhooks/event? true} [{:keys [pool] :as cfg} params] (db/with-atomic [conn pool] (duplicate-project conn params))) @@ -323,7 +326,8 @@ (sv/defmethod ::move-files "Move a set of files from one project to other." - {::doc/added "1.16"} + {::doc/added "1.16" + ::webhooks/event? true} [{:keys [pool] :as cfg} params] (db/with-atomic [conn pool] (move-files conn params))) @@ -362,7 +366,8 @@ (sv/defmethod ::move-project "Move projects between teams." - {::doc/added "1.16"} + {::doc/added "1.16" + ::webhooks/event? true} [{:keys [pool] :as cfg} params] (db/with-atomic [conn pool] (move-project conn params))) @@ -377,7 +382,8 @@ (sv/defmethod ::clone-template "Clone into the specified project the template by its id." - {::doc/added "1.16"} + {::doc/added "1.16" + ::webhooks/event? true} [{:keys [pool] :as cfg} params] (db/with-atomic [conn pool] (-> (assoc cfg :conn conn)