🎉 Manage file images as assets

This commit is contained in:
Andrés Moya 2020-07-23 17:11:36 +02:00
parent 8f8dc80cad
commit 8c8b5887d6
14 changed files with 482 additions and 18 deletions

2
backend/scripts/psql.sh Executable file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env bash
PGPASSWORD=$UXBOX_DATABASE_PASSWORD psql $UXBOX_DATABASE_URI -U $UXBOX_DATABASE_USERNAME

View file

@ -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)

View file

@ -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}]