mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 12:59:12 -05:00
🐛 Fix several rpc events not emiting webhooks
This commit is contained in:
parent
93956ae384
commit
1564f589b9
4 changed files with 50 additions and 25 deletions
|
@ -15,10 +15,12 @@
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
|
[app.loggers.audit :as-alias audit]
|
||||||
[app.loggers.webhooks :as-alias webhooks]
|
[app.loggers.webhooks :as-alias webhooks]
|
||||||
[app.media :as media]
|
[app.media :as media]
|
||||||
[app.rpc.commands.files :as files]
|
[app.rpc.commands.files :as files]
|
||||||
[app.rpc.doc :as-alias doc]
|
[app.rpc.doc :as-alias doc]
|
||||||
|
[app.rpc.helpers :as rph]
|
||||||
[app.rpc.queries.projects :as projects]
|
[app.rpc.queries.projects :as projects]
|
||||||
[app.storage :as sto]
|
[app.storage :as sto]
|
||||||
[app.storage.tmp :as tmp]
|
[app.storage.tmp :as tmp]
|
||||||
|
@ -899,7 +901,9 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [profile-id project-id file] :as params}]
|
[{:keys [pool] :as cfg} {:keys [profile-id project-id file] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(projects/check-read-permissions! conn profile-id project-id)
|
(projects/check-read-permissions! conn profile-id project-id)
|
||||||
(import! (assoc cfg
|
(let [ids (import! (assoc cfg
|
||||||
::input (:path file)
|
::input (:path file)
|
||||||
::project-id project-id
|
::project-id project-id
|
||||||
::ignore-index-errors? true))))
|
::ignore-index-errors? true))]
|
||||||
|
(rph/with-meta ids
|
||||||
|
{::audit/props {:file nil :file-ids ids}}))))
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
[app.common.types.shape-tree :as ctt]
|
[app.common.types.shape-tree :as ctt]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.db.sql :as sql]
|
[app.db.sql :as sql]
|
||||||
|
[app.loggers.audit :as-alias audit]
|
||||||
[app.loggers.webhooks :as-alias webhooks]
|
[app.loggers.webhooks :as-alias webhooks]
|
||||||
[app.rpc.commands.files.thumbnails :as-alias thumbs]
|
[app.rpc.commands.files.thumbnails :as-alias thumbs]
|
||||||
[app.rpc.commands.teams :as teams]
|
[app.rpc.commands.teams :as teams]
|
||||||
|
@ -753,11 +754,10 @@
|
||||||
|
|
||||||
(defn rename-file
|
(defn rename-file
|
||||||
[conn {:keys [id name] :as params}]
|
[conn {:keys [id name] :as params}]
|
||||||
(-> (db/update! conn :file
|
(db/update! conn :file
|
||||||
{:name name
|
{:name name
|
||||||
:modified-at (dt/now)}
|
:modified-at (dt/now)}
|
||||||
{:id id})
|
{:id id}))
|
||||||
(select-keys [:id :name :created-at :modified-at])))
|
|
||||||
|
|
||||||
(s/def ::rename-file
|
(s/def ::rename-file
|
||||||
(s/keys :req-un [::profile-id ::name ::id]))
|
(s/keys :req-un [::profile-id ::name ::id]))
|
||||||
|
@ -768,8 +768,12 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [id profile-id] :as params}]
|
[{:keys [pool] :as cfg} {:keys [id profile-id] :as params}]
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(check-edition-permissions! conn profile-id id)
|
(check-edition-permissions! conn profile-id id)
|
||||||
(rename-file conn params)))
|
(let [file (rename-file conn params)]
|
||||||
|
(rph/with-meta
|
||||||
|
(select-keys file [:id :name :created-at :modified-at])
|
||||||
|
{::audit/props {:project-id (:project-id file)
|
||||||
|
:created-at (:created-at file)
|
||||||
|
:modified-at (:modified-at file)}}))))
|
||||||
|
|
||||||
;; --- MUTATION COMMAND: set-file-shared
|
;; --- MUTATION COMMAND: set-file-shared
|
||||||
|
|
||||||
|
@ -779,10 +783,9 @@
|
||||||
|
|
||||||
(defn set-file-shared
|
(defn set-file-shared
|
||||||
[conn {:keys [id is-shared] :as params}]
|
[conn {:keys [id is-shared] :as params}]
|
||||||
(-> (db/update! conn :file
|
(db/update! conn :file
|
||||||
{:is-shared is-shared}
|
{:is-shared is-shared}
|
||||||
{:id id})
|
{:id id}))
|
||||||
(select-keys [:id :name :is-shared])))
|
|
||||||
|
|
||||||
(defn absorb-library
|
(defn absorb-library
|
||||||
"Find all files using a shared library, and absorb all library assets
|
"Find all files using a shared library, and absorb all library assets
|
||||||
|
@ -816,8 +819,13 @@
|
||||||
(when-not is-shared
|
(when-not is-shared
|
||||||
(absorb-library conn params)
|
(absorb-library conn params)
|
||||||
(unlink-files conn params))
|
(unlink-files conn params))
|
||||||
(set-file-shared conn params)))
|
|
||||||
|
|
||||||
|
(let [file (set-file-shared conn params)]
|
||||||
|
(rph/with-meta
|
||||||
|
(select-keys file [:id :name :is-shared])
|
||||||
|
{::audit/props {:name (:name file)
|
||||||
|
:project-id (:project-id file)
|
||||||
|
:is-shared (:is-shared file)}}))))
|
||||||
|
|
||||||
;; --- MUTATION COMMAND: delete-file
|
;; --- MUTATION COMMAND: delete-file
|
||||||
|
|
||||||
|
@ -825,8 +833,7 @@
|
||||||
[conn {:keys [id] :as params}]
|
[conn {:keys [id] :as params}]
|
||||||
(db/update! conn :file
|
(db/update! conn :file
|
||||||
{:deleted-at (dt/now)}
|
{:deleted-at (dt/now)}
|
||||||
{:id id})
|
{:id id}))
|
||||||
nil)
|
|
||||||
|
|
||||||
(s/def ::delete-file
|
(s/def ::delete-file
|
||||||
(s/keys :req-un [::id ::profile-id]))
|
(s/keys :req-un [::id ::profile-id]))
|
||||||
|
@ -838,7 +845,12 @@
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(check-edition-permissions! conn profile-id id)
|
(check-edition-permissions! conn profile-id id)
|
||||||
(absorb-library conn params)
|
(absorb-library conn params)
|
||||||
(mark-file-deleted conn params)))
|
(let [file (mark-file-deleted conn params)]
|
||||||
|
(rph/with-meta (rph/wrap)
|
||||||
|
{::audit/props {:project-id (:project-id file)
|
||||||
|
:name (:name file)
|
||||||
|
:created-at (:created-at file)
|
||||||
|
:modified-at (:modified-at file)}}))))
|
||||||
|
|
||||||
;; --- MUTATION COMMAND: link-file-to-library
|
;; --- MUTATION COMMAND: link-file-to-library
|
||||||
|
|
||||||
|
|
|
@ -122,4 +122,7 @@
|
||||||
{:deleted-at (dt/now)}
|
{:deleted-at (dt/now)}
|
||||||
{:id id :is-default false})]
|
{:id id :is-default false})]
|
||||||
(rph/with-meta (rph/wrap)
|
(rph/with-meta (rph/wrap)
|
||||||
{::audit/props {:team-id (:team-id project)}}))))
|
{::audit/props {:team-id (:team-id project)
|
||||||
|
:name (:name project)
|
||||||
|
:created-at (:created-at project)
|
||||||
|
:modified-at (:modified-at project)}}))))
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
[lambdaisland.uri :as luri]
|
[lambdaisland.uri :as luri]
|
||||||
[linked.core :as lk]
|
[linked.core :as lk]
|
||||||
[linked.set :as lks]
|
[linked.set :as lks]
|
||||||
|
#?(:clj [datoteka.fs :as fs])
|
||||||
#?(:cljs ["luxon" :as lxn]))
|
#?(:cljs ["luxon" :as lxn]))
|
||||||
#?(:clj
|
#?(:clj
|
||||||
(:import
|
(:import
|
||||||
|
@ -22,6 +23,7 @@
|
||||||
java.io.ByteArrayInputStream
|
java.io.ByteArrayInputStream
|
||||||
java.io.ByteArrayOutputStream
|
java.io.ByteArrayOutputStream
|
||||||
java.io.File
|
java.io.File
|
||||||
|
java.nio.file.Path
|
||||||
java.time.Duration
|
java.time.Duration
|
||||||
java.time.Instant
|
java.time.Instant
|
||||||
java.time.OffsetDateTime
|
java.time.OffsetDateTime
|
||||||
|
@ -102,11 +104,15 @@
|
||||||
;; --- HANDLERS
|
;; --- HANDLERS
|
||||||
|
|
||||||
(add-handlers!
|
(add-handlers!
|
||||||
#?(:clj
|
#?@(:clj
|
||||||
{:id "file"
|
[{:id "file"
|
||||||
:class File
|
:class File
|
||||||
:wfn str
|
:wfn str
|
||||||
:rfn identity})
|
:rfn identity}
|
||||||
|
{:id "path"
|
||||||
|
:class Path
|
||||||
|
:wfn str
|
||||||
|
:rfn fs/path}])
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
{:id "n"
|
{:id "n"
|
||||||
|
|
Loading…
Add table
Reference in a new issue