mirror of
https://github.com/penpot/penpot.git
synced 2025-01-25 07:58:49 -05:00
📎 Properly deprecate comments related queries
This commit is contained in:
parent
61f2799e49
commit
173f0d68bb
3 changed files with 31 additions and 47 deletions
|
@ -130,9 +130,16 @@
|
||||||
(-> (db/exec-one! conn [sql profile-id file-id id])
|
(-> (db/exec-one! conn [sql profile-id file-id id])
|
||||||
(decode-row)))))
|
(decode-row)))))
|
||||||
|
|
||||||
;; --- COMMAND: Comments
|
(defn get-comment-thread
|
||||||
|
[conn {:keys [profile-id file-id id share-id] :as params}]
|
||||||
|
(let [sql (str "with threads as (" sql:comment-threads ")"
|
||||||
|
"select * from threads where id = ?")]
|
||||||
|
(-> (db/exec-one! conn [sql profile-id file-id id])
|
||||||
|
(decode-row))))
|
||||||
|
|
||||||
(declare retrieve-comments)
|
;; --- COMMAND: Retrieve Comments
|
||||||
|
|
||||||
|
(declare get-comments)
|
||||||
|
|
||||||
(s/def ::file-id ::us/uuid)
|
(s/def ::file-id ::us/uuid)
|
||||||
(s/def ::share-id (s/nilable ::us/uuid))
|
(s/def ::share-id (s/nilable ::us/uuid))
|
||||||
|
@ -145,22 +152,24 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [profile-id thread-id share-id] :as params}]
|
[{:keys [pool] :as cfg} {:keys [profile-id thread-id share-id] :as params}]
|
||||||
(with-open [conn (db/open pool)]
|
(with-open [conn (db/open pool)]
|
||||||
(let [thread (db/get-by-id conn :comment-thread thread-id)]
|
(let [thread (db/get-by-id conn :comment-thread thread-id)]
|
||||||
(files/check-comment-permissions! conn profile-id (:file-id thread) share-id)
|
(files/check-comment-permissions! conn profile-id (:file-id thread) share-id))
|
||||||
(retrieve-comments conn thread-id))))
|
(get-comments conn thread-id)))
|
||||||
|
|
||||||
(def sql:comments
|
(def sql:comments
|
||||||
"select c.* from comment as c
|
"select c.* from comment as c
|
||||||
where c.thread_id = ?
|
where c.thread_id = ?
|
||||||
order by c.created_at asc")
|
order by c.created_at asc")
|
||||||
|
|
||||||
(defn retrieve-comments
|
(defn get-comments
|
||||||
[conn thread-id]
|
[conn thread-id]
|
||||||
(->> (db/exec! conn [sql:comments thread-id])
|
(->> (db/query conn :comment
|
||||||
|
{:thread-id thread-id}
|
||||||
|
{:order-by [[:created-at :asc]]})
|
||||||
(into [] (map decode-row))))
|
(into [] (map decode-row))))
|
||||||
|
|
||||||
;; --- COMMAND: Get file comments users
|
;; --- COMMAND: Get file comments users
|
||||||
|
|
||||||
(declare retrieve-file-comments-users)
|
(declare get-file-comments-users)
|
||||||
|
|
||||||
(s/def ::file-id ::us/uuid)
|
(s/def ::file-id ::us/uuid)
|
||||||
(s/def ::share-id (s/nilable ::us/uuid))
|
(s/def ::share-id (s/nilable ::us/uuid))
|
||||||
|
@ -177,7 +186,7 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [profile-id file-id share-id]}]
|
[{:keys [pool] :as cfg} {:keys [profile-id file-id share-id]}]
|
||||||
(with-open [conn (db/open pool)]
|
(with-open [conn (db/open pool)]
|
||||||
(files/check-comment-permissions! conn profile-id file-id share-id)
|
(files/check-comment-permissions! conn profile-id file-id share-id)
|
||||||
(retrieve-file-comments-users conn file-id profile-id)))
|
(get-file-comments-users conn file-id profile-id)))
|
||||||
|
|
||||||
;; All the profiles that had comment the file, plus the current
|
;; All the profiles that had comment the file, plus the current
|
||||||
;; profile.
|
;; profile.
|
||||||
|
@ -197,6 +206,6 @@
|
||||||
FROM profile AS p
|
FROM profile AS p
|
||||||
WHERE p.id IN (SELECT id FROM available_profiles) OR p.id=?")
|
WHERE p.id IN (SELECT id FROM available_profiles) OR p.id=?")
|
||||||
|
|
||||||
(defn retrieve-file-comments-users
|
(defn get-file-comments-users
|
||||||
[conn file-id profile-id]
|
[conn file-id profile-id]
|
||||||
(db/exec! conn [sql:file-comment-users file-id profile-id]))
|
(db/exec! conn [sql:file-comment-users file-id profile-id]))
|
||||||
|
|
|
@ -23,27 +23,18 @@
|
||||||
|
|
||||||
;; --- QUERY: Comment Threads
|
;; --- QUERY: Comment Threads
|
||||||
|
|
||||||
(s/def ::team-id ::us/uuid)
|
(s/def ::comment-threads ::cmd.comments/get-comment-threads)
|
||||||
(s/def ::file-id ::us/uuid)
|
|
||||||
(s/def ::share-id (s/nilable ::us/uuid))
|
|
||||||
|
|
||||||
(s/def ::comment-threads
|
|
||||||
(s/and (s/keys :req-un [::profile-id]
|
|
||||||
:opt-un [::file-id ::share-id ::team-id])
|
|
||||||
#(or (:file-id %) (:team-id %))))
|
|
||||||
|
|
||||||
(sv/defmethod ::comment-threads
|
(sv/defmethod ::comment-threads
|
||||||
{::doc/deprecated "1.15"}
|
{::doc/added "1.0"
|
||||||
|
::doc/deprecated "1.15"}
|
||||||
[{:keys [pool] :as cfg} params]
|
[{:keys [pool] :as cfg} params]
|
||||||
(with-open [conn (db/open pool)]
|
(with-open [conn (db/open pool)]
|
||||||
(cmd.comments/retrieve-comment-threads conn params)))
|
(cmd.comments/retrieve-comment-threads conn params)))
|
||||||
|
|
||||||
|
|
||||||
;; --- QUERY: Unread Comment Threads
|
;; --- QUERY: Unread Comment Threads
|
||||||
|
|
||||||
(s/def ::team-id ::us/uuid)
|
(s/def ::unread-comment-threads ::cmd.comments/get-unread-comment-threads)
|
||||||
(s/def ::unread-comment-threads
|
|
||||||
(s/keys :req-un [::profile-id ::team-id]))
|
|
||||||
|
|
||||||
(sv/defmethod ::unread-comment-threads
|
(sv/defmethod ::unread-comment-threads
|
||||||
{::doc/added "1.0"
|
{::doc/added "1.0"
|
||||||
|
@ -55,11 +46,7 @@
|
||||||
|
|
||||||
;; --- QUERY: Single Comment Thread
|
;; --- QUERY: Single Comment Thread
|
||||||
|
|
||||||
(s/def ::id ::us/uuid)
|
(s/def ::comment-thread ::cmd.comments/get-comment-thread)
|
||||||
(s/def ::share-id (s/nilable ::us/uuid))
|
|
||||||
(s/def ::comment-thread
|
|
||||||
(s/keys :req-un [::profile-id ::file-id ::id]
|
|
||||||
:opt-un [::share-id]))
|
|
||||||
|
|
||||||
(sv/defmethod ::comment-thread
|
(sv/defmethod ::comment-thread
|
||||||
{::doc/added "1.0"
|
{::doc/added "1.0"
|
||||||
|
@ -67,19 +54,11 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [profile-id file-id id share-id] :as params}]
|
[{:keys [pool] :as cfg} {:keys [profile-id file-id id share-id] :as params}]
|
||||||
(with-open [conn (db/open pool)]
|
(with-open [conn (db/open pool)]
|
||||||
(files/check-comment-permissions! conn profile-id file-id share-id)
|
(files/check-comment-permissions! conn profile-id file-id share-id)
|
||||||
(let [sql (str "with threads as (" cmd.comments/sql:comment-threads ")"
|
(cmd.comments/get-comment-thread conn params)))
|
||||||
"select * from threads where id = ?")]
|
|
||||||
(-> (db/exec-one! conn [sql profile-id file-id id])
|
|
||||||
(decode-row)))))
|
|
||||||
|
|
||||||
;; --- QUERY: Comments
|
;; --- QUERY: Comments
|
||||||
|
|
||||||
(s/def ::file-id ::us/uuid)
|
(s/def ::comments ::cmd.comments/get-comments)
|
||||||
(s/def ::share-id (s/nilable ::us/uuid))
|
|
||||||
(s/def ::thread-id ::us/uuid)
|
|
||||||
(s/def ::comments
|
|
||||||
(s/keys :req-un [::profile-id ::thread-id]
|
|
||||||
:opt-un [::share-id]))
|
|
||||||
|
|
||||||
(sv/defmethod ::comments
|
(sv/defmethod ::comments
|
||||||
{::doc/added "1.0"
|
{::doc/added "1.0"
|
||||||
|
@ -87,17 +66,13 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [profile-id thread-id share-id] :as params}]
|
[{:keys [pool] :as cfg} {:keys [profile-id thread-id share-id] :as params}]
|
||||||
(with-open [conn (db/open pool)]
|
(with-open [conn (db/open pool)]
|
||||||
(let [thread (db/get-by-id conn :comment-thread thread-id)]
|
(let [thread (db/get-by-id conn :comment-thread thread-id)]
|
||||||
(files/check-comment-permissions! conn profile-id (:file-id thread) share-id)
|
(files/check-comment-permissions! conn profile-id (:file-id thread) share-id))
|
||||||
(cmd.comments/retrieve-comments conn thread-id))))
|
(cmd.comments/get-comments conn thread-id)))
|
||||||
|
|
||||||
|
|
||||||
;; --- QUERY: Get file comments users
|
;; --- QUERY: Get file comments users
|
||||||
|
|
||||||
(s/def ::file-id ::us/uuid)
|
(s/def ::file-comments-users ::cmd.comments/get-profiles-for-file-comments)
|
||||||
(s/def ::share-id (s/nilable ::us/uuid))
|
|
||||||
|
|
||||||
(s/def ::file-comments-users
|
|
||||||
(s/keys :req-un [::profile-id ::file-id]
|
|
||||||
:opt-un [::share-id]))
|
|
||||||
|
|
||||||
(sv/defmethod ::file-comments-users
|
(sv/defmethod ::file-comments-users
|
||||||
{::doc/deprecated "1.15"
|
{::doc/deprecated "1.15"
|
||||||
|
@ -105,4 +80,4 @@
|
||||||
[{:keys [pool] :as cfg} {:keys [profile-id file-id share-id]}]
|
[{:keys [pool] :as cfg} {:keys [profile-id file-id share-id]}]
|
||||||
(with-open [conn (db/open pool)]
|
(with-open [conn (db/open pool)]
|
||||||
(files/check-comment-permissions! conn profile-id file-id share-id)
|
(files/check-comment-permissions! conn profile-id file-id share-id)
|
||||||
(cmd.comments/retrieve-file-comments-users conn file-id profile-id)))
|
(cmd.comments/get-file-comments-users conn file-id profile-id)))
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
(p/let [file (files/retrieve-file cfg file-id)
|
(p/let [file (files/retrieve-file cfg file-id)
|
||||||
project (retrieve-project pool (:project-id file))
|
project (retrieve-project pool (:project-id file))
|
||||||
libs (files/retrieve-file-libraries cfg false file-id)
|
libs (files/retrieve-file-libraries cfg false file-id)
|
||||||
users (comments/retrieve-file-comments-users pool file-id profile-id)
|
users (comments/get-file-comments-users pool file-id profile-id)
|
||||||
|
|
||||||
links (->> (db/query pool :share-link {:file-id file-id})
|
links (->> (db/query pool :share-link {:file-id file-id})
|
||||||
(mapv slnk/decode-share-link-row))
|
(mapv slnk/decode-share-link-row))
|
||||||
|
|
Loading…
Add table
Reference in a new issue