mirror of
https://github.com/penpot/penpot.git
synced 2025-07-16 21:25:16 +02:00
✨ Reuse permission from rpc/cond middleware for get-file rpc method
This commit is contained in:
parent
22d7cfc7fa
commit
40d7bb04b4
3 changed files with 17 additions and 5 deletions
|
@ -295,8 +295,16 @@
|
|||
::sm/result schema:file-with-permissions}
|
||||
[cfg {:keys [::rpc/profile-id id project-id] :as params}]
|
||||
(db/tx-run! cfg (fn [{:keys [::db/conn] :as cfg}]
|
||||
(let [perms (get-permissions conn profile-id id)]
|
||||
;; The COND middleware makes initial request for a file and
|
||||
;; permissions when the incoming request comes with an
|
||||
;; ETAG. When ETAG does not matches, the request is resolved
|
||||
;; and this code is executed, in this case the permissions
|
||||
;; will be already prefetched and we just reuse them instead
|
||||
;; of making an additional database queries.
|
||||
(let [perms (or (:permissions (::cond/object params))
|
||||
(get-permissions conn profile-id id))]
|
||||
(check-read-permissions! perms)
|
||||
|
||||
(let [team (teams/get-team conn
|
||||
:profile-id profile-id
|
||||
:project-id project-id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue