mirror of
https://github.com/penpot/penpot.git
synced 2026-09-08 13:09:22 +00:00
🐛 Fix share-link viewers unable to load file fragments (#11484)
This commit is contained in:
parent
7c762d8a98
commit
80dea409c6
@ -241,6 +241,18 @@
|
||||
(some-> (db/get cfg :file-data {:file-id file-id :id fragment-id :type "fragment"})
|
||||
(update :data blob/decode)))
|
||||
|
||||
(defn- check-fragment-scope!
|
||||
"Checks that the fragment is reachable from the pages authorized by
|
||||
the share-link. Raises a :not-found exception if the fragment is not reachable."
|
||||
[cfg file-id fragment-id pages]
|
||||
(let [fdata (-> (bfc/get-file cfg file-id :read-only? true)
|
||||
(get :data)
|
||||
(update :pages-index select-keys pages))]
|
||||
(when-not (contains? (feat.fdata/get-used-pointer-ids fdata) fragment-id)
|
||||
(ex/raise :type :not-found
|
||||
:code :object-not-found
|
||||
:hint "object not found"))))
|
||||
|
||||
(sv/defmethod ::get-file-fragment
|
||||
"Retrieve a file fragment by its ID. Only authenticated users."
|
||||
{::doc/added "1.17"
|
||||
@ -250,11 +262,9 @@
|
||||
[cfg {:keys [::rpc/profile-id file-id fragment-id share-id]}]
|
||||
(db/run! cfg (fn [cfg]
|
||||
(let [perms (perms/get-file-read-permissions cfg profile-id file-id share-id)]
|
||||
(when (= :share-link (:type perms))
|
||||
(ex/raise :type :not-found
|
||||
:code :object-not-found
|
||||
:hint "object not found"))
|
||||
(check-read-permissions! perms)
|
||||
(when (= :share-link (:type perms))
|
||||
(check-fragment-scope! cfg file-id fragment-id (:pages perms)))
|
||||
(-> (get-file-fragment cfg file-id fragment-id)
|
||||
(rph/with-http-cache long-cache-duration))))))
|
||||
|
||||
|
||||
@ -326,11 +326,12 @@
|
||||
(filter #(= page-id (:page-id %)))
|
||||
(d/index-by :id)
|
||||
(assoc state :comment-threads)))
|
||||
(on-error [{:keys [type] :as err}]
|
||||
(if (or (= :authentication type)
|
||||
(= :not-found type))
|
||||
(rx/empty)
|
||||
(rx/throw err)))]
|
||||
(on-error [cause]
|
||||
(let [{:keys [type]} (ex-data cause)]
|
||||
(if (or (= :authentication type)
|
||||
(= :not-found type))
|
||||
(rx/empty)
|
||||
(rx/throw cause))))]
|
||||
|
||||
(ptk/reify ::fetch-comment-threads
|
||||
ptk/WatchEvent
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user