Make file to library link idempotent.

And remove unused api calls.
This commit is contained in:
Andrey Antukh 2020-11-19 17:23:26 +01:00 committed by Alonso Torres
parent b2957c5f35
commit fca48e39ee
4 changed files with 16 additions and 47 deletions

View file

@ -162,11 +162,14 @@
(files/check-edition-permissions! conn profile-id file-id)
(link-file-to-library conn params)))
(def sql:link-file-to-library
"insert into file_library_rel (file_id, library_file_id)
values (?, ?)
on conflict do nothing;")
(defn- link-file-to-library
[conn {:keys [file-id library-id] :as params}]
(db/insert! conn :file-library-rel
{:file-id file-id
:library-file-id library-id}))
(db/exec-one! conn [sql:link-file-to-library file-id library-id]))
;; --- Mutation: Unlink file from library

View file

@ -38,7 +38,6 @@
(s/def ::team-id ::us/uuid)
(s/def ::url ::us/url)
;; --- Create Media object (Upload and create from url)
(declare create-media-object)

View file

@ -55,13 +55,3 @@
[conn {:keys [id] :as props}]
(let [sql "delete from media_object where id=? and deleted_at is not null"]
(db/exec-one! conn [sql id])))
(defmethod handle-deletion :color
[conn {:keys [id] :as props}]
(let [sql "delete from color where id=? and deleted_at is not null"]
(db/exec-one! conn [sql id])))
(defmethod handle-deletion :page
[conn {:keys [id] :as props}]
(let [sql "delete from page where id=? and deleted_at is not null"]
(db/exec-one! conn [sql id])))