mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 00:46:38 +02:00
🎉 Manage file images as assets
This commit is contained in:
parent
8f8dc80cad
commit
8c8b5887d6
14 changed files with 482 additions and 18 deletions
2
backend/scripts/psql.sh
Executable file
2
backend/scripts/psql.sh
Executable file
|
@ -0,0 +1,2 @@
|
|||
#!/usr/bin/env bash
|
||||
PGPASSWORD=$UXBOX_DATABASE_PASSWORD psql $UXBOX_DATABASE_URI -U $UXBOX_DATABASE_USERNAME
|
|
@ -133,6 +133,7 @@
|
|||
(declare create-file-image)
|
||||
|
||||
(s/def ::file-id ::us/uuid)
|
||||
(s/def ::image-id ::us/uuid)
|
||||
(s/def ::content ::imgs/upload)
|
||||
|
||||
(s/def ::add-file-image-from-url
|
||||
|
@ -189,6 +190,33 @@
|
|||
(images/resolve-urls :thumb-path :thumb-uri))))
|
||||
|
||||
|
||||
;; --- Mutation: Delete File Image
|
||||
|
||||
(declare mark-file-image-deleted)
|
||||
|
||||
(s/def ::delete-file-image
|
||||
(s/keys :req-un [::file-id ::image-id ::profile-id]))
|
||||
|
||||
(sm/defmutation ::delete-file-image
|
||||
[{:keys [file-id image-id profile-id] :as params}]
|
||||
(db/with-atomic [conn db/pool]
|
||||
(files/check-edition-permissions! conn profile-id file-id)
|
||||
|
||||
;; Schedule object deletion
|
||||
(tasks/submit! conn {:name "delete-object"
|
||||
:delay cfg/default-deletion-delay
|
||||
:props {:id image-id :type :file-image}})
|
||||
|
||||
(mark-file-image-deleted conn params)))
|
||||
|
||||
(defn mark-file-image-deleted
|
||||
[conn {:keys [image-id] :as params}]
|
||||
(db/update! conn :file-image
|
||||
{:deleted-at (dt/now)}
|
||||
{:id image-id})
|
||||
nil)
|
||||
|
||||
|
||||
;; --- Mutation: Import from collection
|
||||
|
||||
(declare copy-image)
|
||||
|
|
|
@ -169,7 +169,8 @@
|
|||
(def ^:private sql:file-images
|
||||
"select fi.*
|
||||
from file_image as fi
|
||||
where fi.file_id = ?")
|
||||
where fi.file_id = ?
|
||||
and fi.deleted_at is null")
|
||||
|
||||
(defn retrieve-file-images
|
||||
[conn {:keys [file-id] :as params}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue