diff --git a/backend/src/app/http/debug.clj b/backend/src/app/http/debug.clj index 3afa932fd..5e0596256 100644 --- a/backend/src/app/http/debug.clj +++ b/backend/src/app/http/debug.clj @@ -24,7 +24,7 @@ [app.rpc.commands.profile :as profile] [app.rpc.commands.teams :as teams] [app.setup :as-alias setup] - [app.srepl.helpers :as srepl] + [app.srepl.main :as srepl] [app.storage :as-alias sto] [app.storage.tmp :as tmp] [app.util.blob :as blob] diff --git a/backend/src/app/srepl/helpers.clj b/backend/src/app/srepl/helpers.clj index 31e6ca765..d8293253e 100644 --- a/backend/src/app/srepl/helpers.clj +++ b/backend/src/app/srepl/helpers.clj @@ -10,15 +10,12 @@ (:require [app.binfile.common :as bfc] [app.common.data :as d] - [app.common.exceptions :as ex] - [app.common.features :as cfeat] [app.common.files.validate :as cfv] [app.db :as db] [app.features.components-v2 :as feat.comp-v2] [app.main :as main] [app.rpc.commands.files :as files] [app.rpc.commands.files-snapshot :as fsnap] - [app.srepl.helpers :as h] [app.util.time :as dt])) (def ^:dynamic *system* nil) @@ -88,44 +85,6 @@ WHERE file_id = ANY(?) AND id IS NOT NULL") -(defn enable-team-feature! - [team-id feature & {:keys [skip-check] :or {skip-check false}}] - (when (and (not skip-check) (not (contains? cfeat/supported-features feature))) - (ex/raise :type :assertion - :code :feature-not-supported - :hint (str "feature '" feature "' not supported"))) - - (let [team-id (h/parse-uuid team-id)] - (db/tx-run! main/system - (fn [{:keys [::db/conn]}] - (let [team (-> (db/get conn :team {:id team-id}) - (update :features db/decode-pgarray #{})) - features (conj (:features team) feature)] - (when (not= features (:features team)) - (db/update! conn :team - {:features (db/create-array conn "text" features)} - {:id team-id}) - :enabled)))))) - -(defn disable-team-feature! - [team-id feature & {:keys [skip-check] :or {skip-check false}}] - (when (and (not skip-check) (not (contains? cfeat/supported-features feature))) - (ex/raise :type :assertion - :code :feature-not-supported - :hint (str "feature '" feature "' not supported"))) - - (let [team-id (h/parse-uuid team-id)] - (db/tx-run! main/system - (fn [{:keys [::db/conn]}] - (let [team (-> (db/get conn :team {:id team-id}) - (update :features db/decode-pgarray #{})) - features (disj (:features team) feature)] - (when (not= features (:features team)) - (db/update! conn :team - {:features (db/create-array conn "text" features)} - {:id team-id}) - :disabled)))))) - (defn search-file-snapshots "Get a seq parirs of file-id and snapshot-id for a set of files and specified label" diff --git a/backend/src/app/srepl/main.clj b/backend/src/app/srepl/main.clj index db818c457..be5c9e57d 100644 --- a/backend/src/app/srepl/main.clj +++ b/backend/src/app/srepl/main.clj @@ -161,6 +161,43 @@ (enable-objects-map-feature-on-file! file-id opts) (enable-pointer-map-feature-on-file! file-id opts)) +(defn enable-team-feature! + [team-id feature & {:keys [skip-check] :or {skip-check false}}] + (when (and (not skip-check) (not (contains? cfeat/supported-features feature))) + (ex/raise :type :assertion + :code :feature-not-supported + :hint (str "feature '" feature "' not supported"))) + + (let [team-id (h/parse-uuid team-id)] + (db/tx-run! main/system + (fn [{:keys [::db/conn]}] + (let [team (-> (db/get conn :team {:id team-id}) + (update :features db/decode-pgarray #{})) + features (conj (:features team) feature)] + (when (not= features (:features team)) + (db/update! conn :team + {:features (db/create-array conn "text" features)} + {:id team-id}) + :enabled)))))) + +(defn disable-team-feature! + [team-id feature & {:keys [skip-check] :or {skip-check false}}] + (when (and (not skip-check) (not (contains? cfeat/supported-features feature))) + (ex/raise :type :assertion + :code :feature-not-supported + :hint (str "feature '" feature "' not supported"))) + + (let [team-id (h/parse-uuid team-id)] + (db/tx-run! main/system + (fn [{:keys [::db/conn]}] + (let [team (-> (db/get conn :team {:id team-id}) + (update :features db/decode-pgarray #{})) + features (disj (:features team) feature)] + (when (not= features (:features team)) + (db/update! conn :team + {:features (db/create-array conn "text" features)} + {:id team-id}) + :disabled)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; NOTIFICATIONS