diff --git a/CHANGES.md b/CHANGES.md index 9e84046234..3533a6197b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ - Fix design tab has a horizontal scroll [Taiga #10660](https://tree.taiga.io/project/penpot/issue/10660) - Fix long file names being clipped when longer than allowed length [Taiga #10662](https://tree.taiga.io/project/penpot/issue/10662) - Fix problem with error detail in toast [Taiga #10519](https://tree.taiga.io/project/penpot/issue/10519) +- Fix view mode error when an external user tries to export something from a prototype using a shared link [Taiga #10251](https://tree.taiga.io/project/penpot/issue/10251) ## 2.6.1 diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index 39b3d6c029..36d0c1c3df 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -474,7 +474,7 @@ (update page :objects update-vals #(dissoc % :thumbnail))) (defn get-page - [{:keys [::db/conn] :as cfg} {:keys [profile-id file-id page-id object-id] :as params}] + [{:keys [::db/conn] :as cfg} {:keys [profile-id file-id page-id object-id share-id] :as params}] (when (and (uuid? object-id) (not (uuid? page-id))) @@ -482,22 +482,30 @@ :code :params-validation :hint "page-id is required when object-id is provided")) - (let [team (teams/get-team conn - :profile-id profile-id - :file-id file-id) + (let [perms (get-permissions conn profile-id file-id share-id) - file (get-file cfg file-id) + file (get-file cfg file-id) - _ (-> (cfeat/get-team-enabled-features cf/flags team) - (cfeat/check-client-features! (:features params)) - (cfeat/check-file-features! (:features file))) + proj (db/get conn :project {:id (:project-id file)}) - page (binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg file-id)] - (let [page-id (or page-id (-> file :data :pages first)) - page (dm/get-in file [:data :pages-index page-id])] - (if (pmap/pointer-map? page) - (deref page) - page)))] + team (-> (db/get conn :team {:id (:team-id proj)}) + (teams/decode-row)) + + _ (-> (cfeat/get-team-enabled-features cf/flags team) + (cfeat/check-client-features! (:features params)) + (cfeat/check-file-features! (:features file))) + + page (binding [pmap/*load-fn* (partial feat.fdata/load-pointer cfg file-id)] + (let [page-id (or page-id (-> file :data :pages first)) + page (dm/get-in file [:data :pages-index page-id])] + (if (pmap/pointer-map? page) + (deref page) + page)))] + + (when-not perms + (ex/raise :type :not-found + :code :object-not-found + :hint "object not found")) (cond-> (prune-thumbnails page) (some? object-id) diff --git a/frontend/src/app/render.cljs b/frontend/src/app/render.cljs index bc1fc3f967..90d7f1a0a4 100644 --- a/frontend/src/app/render.cljs +++ b/frontend/src/app/render.cljs @@ -143,17 +143,7 @@ nil) (do - (st/emit! (ptk/reify ::initialize-render-objects - ptk/WatchEvent - (watch [_ _ stream] - (rx/merge - (rx/of (fetch-team :file-id file-id)) - - (->> stream - (rx/filter (ptk/type? ::team-fetched)) - (rx/observe-on :async) - (rx/map (constantly params)) - (rx/map fetch-objects-bundle)))))) + (st/emit! (fetch-objects-bundle :file-id file-id :page-id page-id :share-id share-id :object-id object-id)) (if (uuid? object-id) (mf/html