diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index 61c59a58a..71ffd447c 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -237,7 +237,6 @@ (->> (sv/scan-ns 'app.rpc.queries.projects 'app.rpc.queries.files 'app.rpc.queries.teams - 'app.rpc.queries.comments 'app.rpc.queries.profile 'app.rpc.queries.viewer 'app.rpc.queries.fonts) @@ -250,13 +249,10 @@ (->> (sv/scan-ns 'app.rpc.mutations.media 'app.rpc.mutations.profile 'app.rpc.mutations.files - 'app.rpc.mutations.comments 'app.rpc.mutations.projects 'app.rpc.mutations.teams - 'app.rpc.mutations.management 'app.rpc.mutations.fonts - 'app.rpc.mutations.share-link - 'app.rpc.mutations.verify-token) + 'app.rpc.mutations.share-link) (map (partial process-method cfg)) (into {})))) diff --git a/backend/src/app/rpc/mutations/comments.clj b/backend/src/app/rpc/mutations/comments.clj deleted file mode 100644 index 6b606ba35..000000000 --- a/backend/src/app/rpc/mutations/comments.clj +++ /dev/null @@ -1,123 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.rpc.mutations.comments - (:require - [app.common.exceptions :as ex] - [app.common.spec :as us] - [app.db :as db] - [app.rpc.commands.comments :as cmd.comments] - [app.rpc.commands.files :as cmd.files] - [app.rpc.doc :as-alias doc] - [app.rpc.retry :as retry] - [app.util.services :as sv] - [clojure.spec.alpha :as s])) - -;; --- Mutation: Create Comment Thread - -(s/def ::create-comment-thread ::cmd.comments/create-comment-thread) - -(sv/defmethod ::create-comment-thread - {::retry/max-retries 3 - ::retry/matches retry/conflict-db-insert? - ::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id file-id share-id] :as params}] - (db/with-atomic [conn pool] - (cmd.files/check-comment-permissions! conn profile-id file-id share-id) - (cmd.comments/create-comment-thread conn params))) - -;; --- Mutation: Update Comment Thread Status - -(s/def ::id ::us/uuid) -(s/def ::share-id (s/nilable ::us/uuid)) - -(s/def ::update-comment-thread-status ::cmd.comments/update-comment-thread-status) - -(sv/defmethod ::update-comment-thread-status - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id id share-id] :as params}] - (db/with-atomic [conn pool] - (let [cthr (db/get-by-id conn :comment-thread id {:for-update true})] - (when-not cthr (ex/raise :type :not-found)) - (cmd.files/check-comment-permissions! conn profile-id (:file-id cthr) share-id) - (cmd.comments/upsert-comment-thread-status! conn profile-id (:id cthr))))) - - -;; --- Mutation: Update Comment Thread - -(s/def ::update-comment-thread ::cmd.comments/update-comment-thread) - -(sv/defmethod ::update-comment-thread - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id id is-resolved share-id] :as params}] - (db/with-atomic [conn pool] - (let [thread (db/get-by-id conn :comment-thread id {:for-update true})] - (when-not thread - (ex/raise :type :not-found)) - - (cmd.files/check-comment-permissions! conn profile-id (:file-id thread) share-id) - (db/update! conn :comment-thread - {:is-resolved is-resolved} - {:id id}) - nil))) - - -;; --- Mutation: Add Comment - -(s/def ::add-comment ::cmd.comments/create-comment) - -(sv/defmethod ::add-comment - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} params] - (db/with-atomic [conn pool] - (cmd.comments/create-comment conn params))) - - -;; --- Mutation: Update Comment - -(s/def ::update-comment ::cmd.comments/update-comment) - -(sv/defmethod ::update-comment - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} params] - (db/with-atomic [conn pool] - (cmd.comments/update-comment conn params))) - - -;; --- Mutation: Delete Comment Thread - -(s/def ::delete-comment-thread ::cmd.comments/delete-comment-thread) - -(sv/defmethod ::delete-comment-thread - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id id] :as params}] - (db/with-atomic [conn pool] - (let [thread (db/get-by-id conn :comment-thread id {:for-update true})] - (when-not (= (:owner-id thread) profile-id) - (ex/raise :type :validation :code :not-allowed)) - (db/delete! conn :comment-thread {:id id}) - nil))) - - -;; --- Mutation: Delete comment - -(s/def ::delete-comment ::cmd.comments/delete-comment) - -(sv/defmethod ::delete-comment - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id id] :as params}] - (db/with-atomic [conn pool] - (let [comment (db/get-by-id conn :comment id {:for-update true})] - (when-not (= (:owner-id comment) profile-id) - (ex/raise :type :validation :code :not-allowed)) - (db/delete! conn :comment {:id id})))) diff --git a/backend/src/app/rpc/mutations/management.clj b/backend/src/app/rpc/mutations/management.clj deleted file mode 100644 index e29a5e98e..000000000 --- a/backend/src/app/rpc/mutations/management.clj +++ /dev/null @@ -1,58 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.rpc.mutations.management - "Move & Duplicate RPC methods for files and projects." - (:require - [app.db :as db] - [app.rpc.commands.management :as cmd.mgm] - [app.rpc.doc :as-alias doc] - [app.util.services :as sv] - [clojure.spec.alpha :as s])) - -;; --- MUTATION: Duplicate File - -(s/def ::duplicate-file ::cmd.mgm/duplicate-file) - -(sv/defmethod ::duplicate-file - {::doc/added "1.2" - ::doc/deprecated "1.16"} - [{:keys [pool] :as cfg} params] - (db/with-atomic [conn pool] - (cmd.mgm/duplicate-file conn params))) - -;; --- MUTATION: Duplicate Project - -(s/def ::duplicate-project ::cmd.mgm/duplicate-project) - -(sv/defmethod ::duplicate-project - {::doc/added "1.2" - ::doc/deprecated "1.16"} - [{:keys [pool] :as cfg} params] - (db/with-atomic [conn pool] - (cmd.mgm/duplicate-project conn params))) - -;; --- MUTATION: Move file - -(s/def ::move-files ::cmd.mgm/move-files) - -(sv/defmethod ::move-files - {::doc/added "1.2" - ::doc/deprecated "1.16"} - [{:keys [pool] :as cfg} params] - (db/with-atomic [conn pool] - (cmd.mgm/move-files conn params))) - -;; --- MUTATION: Move project - -(s/def ::move-project ::cmd.mgm/move-project) - -(sv/defmethod ::move-project - {::doc/added "1.2" - ::doc/deprecated "1.16"} - [{:keys [pool] :as cfg} params] - (db/with-atomic [conn pool] - (cmd.mgm/move-project conn params))) diff --git a/backend/src/app/rpc/mutations/verify_token.clj b/backend/src/app/rpc/mutations/verify_token.clj deleted file mode 100644 index a8551847b..000000000 --- a/backend/src/app/rpc/mutations/verify_token.clj +++ /dev/null @@ -1,28 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.rpc.mutations.verify-token - (:require - [app.db :as db] - [app.rpc.commands.verify-token :refer [process-token]] - [app.rpc.doc :as-alias doc] - [app.tokens :as tokens] - [app.util.services :as sv] - [clojure.spec.alpha :as s])) - -(s/def ::verify-token - (s/keys :req-un [::token] - :opt-un [::profile-id])) - -(sv/defmethod ::verify-token - {:auth false - ::doc/added "1.1" - ::doc/deprecated "1.15"} - [{:keys [pool sprops] :as cfg} {:keys [token] :as params}] - (db/with-atomic [conn pool] - (let [claims (tokens/verify sprops {:token token}) - cfg (assoc cfg :conn conn)] - (process-token cfg params claims)))) diff --git a/backend/src/app/rpc/queries/comments.clj b/backend/src/app/rpc/queries/comments.clj deleted file mode 100644 index fbcb86f03..000000000 --- a/backend/src/app/rpc/queries/comments.clj +++ /dev/null @@ -1,82 +0,0 @@ -;; This Source Code Form is subject to the terms of the Mozilla Public -;; License, v. 2.0. If a copy of the MPL was not distributed with this -;; file, You can obtain one at http://mozilla.org/MPL/2.0/. -;; -;; Copyright (c) KALEIDOS INC - -(ns app.rpc.queries.comments - (:require - [app.db :as db] - [app.rpc.commands.comments :as cmd.comments] - [app.rpc.commands.files :as cmd.files] - [app.rpc.commands.teams :as teams] - [app.rpc.doc :as-alias doc] - [app.util.services :as sv] - [clojure.spec.alpha :as s])) - -(defn decode-row - [{:keys [participants position] :as row}] - (cond-> row - (db/pgpoint? position) (assoc :position (db/decode-pgpoint position)) - (db/pgobject? participants) (assoc :participants (db/decode-transit-pgobject participants)))) - -;; --- QUERY: Comment Threads - -(s/def ::comment-threads ::cmd.comments/get-comment-threads) - -(sv/defmethod ::comment-threads - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} params] - (with-open [conn (db/open pool)] - (cmd.comments/retrieve-comment-threads conn params))) - -;; --- QUERY: Unread Comment Threads - -(s/def ::unread-comment-threads ::cmd.comments/get-unread-comment-threads) - -(sv/defmethod ::unread-comment-threads - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id team-id] :as params}] - (with-open [conn (db/open pool)] - (teams/check-read-permissions! conn profile-id team-id) - (cmd.comments/retrieve-unread-comment-threads conn params))) - -;; --- QUERY: Single Comment Thread - -(s/def ::comment-thread ::cmd.comments/get-comment-thread) - -(sv/defmethod ::comment-thread - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id file-id share-id] :as params}] - (with-open [conn (db/open pool)] - (cmd.files/check-comment-permissions! conn profile-id file-id share-id) - (cmd.comments/get-comment-thread conn params))) - -;; --- QUERY: Comments - -(s/def ::comments ::cmd.comments/get-comments) - -(sv/defmethod ::comments - {::doc/added "1.0" - ::doc/deprecated "1.15"} - [{:keys [pool] :as cfg} {:keys [profile-id thread-id share-id] :as params}] - (with-open [conn (db/open pool)] - (let [thread (db/get-by-id conn :comment-thread thread-id)] - (cmd.files/check-comment-permissions! conn profile-id (:file-id thread) share-id)) - (cmd.comments/get-comments conn thread-id))) - - -;; --- QUERY: Get file comments users - -(s/def ::file-comments-users ::cmd.comments/get-profiles-for-file-comments) - -(sv/defmethod ::file-comments-users - {::doc/deprecated "1.15" - ::doc/added "1.13"} - [{:keys [pool] :as cfg} {:keys [profile-id file-id share-id]}] - (with-open [conn (db/open pool)] - (cmd.files/check-comment-permissions! conn profile-id file-id share-id) - (cmd.comments/get-file-comments-users conn file-id profile-id))) diff --git a/backend/test/backend_tests/rpc_management_test.clj b/backend/test/backend_tests/rpc_management_test.clj index c1f03838d..5b4f26d05 100644 --- a/backend/test/backend_tests/rpc_management_test.clj +++ b/backend/test/backend_tests/rpc_management_test.clj @@ -53,7 +53,7 @@ :profile-id (:id profile) :file-id (:id file1) :name "file 1 (copy)"} - out (th/mutation! data)] + out (th/command! data)] ;; (th/print-result! out) @@ -125,7 +125,7 @@ :profile-id (:id profile) :file-id (:id file1) :name "file 1 (copy)"} - out (th/mutation! data)] + out (th/command! data)] ;; (th/print-result! out) @@ -187,7 +187,7 @@ :profile-id (:id profile) :project-id (:id project) :name "project 1 (copy)"} - out (th/mutation! data)] + out (th/command! data)] ;; Check that result is correct (t/is (nil? (:error out))) @@ -253,7 +253,7 @@ :profile-id (:id profile) :project-id (:id project) :name "project 1 (copy)"} - out (th/mutation! data)] + out (th/command! data)] ;; Check that result is correct (t/is (nil? (:error out))) @@ -317,7 +317,7 @@ :project-id (:id project1) :ids #{(:id file1)}} - out (th/mutation! data) + out (th/command! data) error (:error out)] (t/is (th/ex-info? error)) (t/is (th/ex-of-type? error :validation)) @@ -337,7 +337,7 @@ :project-id (:id project2) :ids #{(:id file1)}} - out (th/mutation! data)] + out (th/command! data)] (t/is (nil? (:error out))) (t/is (nil? (:result out))) @@ -419,7 +419,7 @@ :profile-id (:id profile) :project-id (:id project2) :ids #{(:id file1)}} - out (th/mutation! data)] + out (th/command! data)] (t/is (nil? (:error out))) (t/is (nil? (:result out))) @@ -492,7 +492,7 @@ :profile-id (:id profile) :project-id (:id project2) :ids #{(:id file2)}} - out (th/mutation! data)] + out (th/command! data)] (t/is (nil? (:error out))) (t/is (nil? (:result out))) @@ -578,7 +578,7 @@ :profile-id (:id profile) :project-id (:id project1) :team-id (:id team)} - out (th/mutation! data)] + out (th/command! data)] (t/is (nil? (:error out))) (t/is (nil? (:result out))) diff --git a/backend/test/backend_tests/rpc_team_test.clj b/backend/test/backend_tests/rpc_team_test.clj index 302f80dc5..cababafae 100644 --- a/backend/test/backend_tests/rpc_team_test.clj +++ b/backend/test/backend_tests/rpc_team_test.clj @@ -179,7 +179,7 @@ :valid-until (dt/in-future "48h")}) (let [data {::th/type :verify-token :token token} - out (th/mutation! data)] + out (th/command! data)] ;; (th/print-result! out) (t/is (th/success? out)) (let [result (:result out)] @@ -205,7 +205,7 @@ :valid-until (dt/in-future "48h")}) (let [data {::th/type :verify-token :token token :profile-id (:id profile2)} - out (th/mutation! data)] + out (th/command! data)] ;; (th/print-result! out) (t/is (th/success? out)) (let [result (:result out)] @@ -226,7 +226,7 @@ :valid-until (dt/in-future "48h")}) (let [data {::th/type :verify-token :token token :profile-id (:id profile1)} - out (th/mutation! data)] + out (th/command! data)] ;; (th/print-result! out) (t/is (not (th/success? out))) (let [edata (-> out :error ex-data)]