mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 02:36:38 +02:00
♻️ Refactor comments RPC methods and add tests
This commit is contained in:
parent
73a3e0c0ae
commit
27451b9796
10 changed files with 571 additions and 233 deletions
|
@ -151,11 +151,14 @@
|
|||
(def check-read-permissions!
|
||||
(perms/make-check-fn has-read-permissions?))
|
||||
|
||||
;; A user has comment permissions if she has read permissions, or comment permissions
|
||||
;; A user has comment permissions if she has read permissions, or
|
||||
;; explicit comment permissions through the share-id
|
||||
|
||||
(defn check-comment-permissions!
|
||||
[conn profile-id file-id share-id]
|
||||
(let [can-read (has-read-permissions? conn profile-id file-id)
|
||||
can-comment (has-comment-permissions? conn profile-id file-id share-id)]
|
||||
(let [perms (get-permissions conn profile-id file-id share-id)
|
||||
can-read (has-read-permissions? perms)
|
||||
can-comment (has-comment-permissions? perms)]
|
||||
(when-not (or can-read can-comment)
|
||||
(ex/raise :type :not-found
|
||||
:code :object-not-found
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue