mirror of
https://github.com/penpot/penpot.git
synced 2026-09-09 05:28:43 +00:00
✨ Make nitrate module loading conditional to flag
This removes the flag checking on each rpc method
This commit is contained in:
parent
7f27e0326d
commit
89935e2174
@ -298,10 +298,12 @@
|
|||||||
|
|
||||||
(defn- resolve-management-methods
|
(defn- resolve-management-methods
|
||||||
[cfg]
|
[cfg]
|
||||||
(let [cfg (assoc cfg ::type "management" ::metrics-id :rpc-management-timing)]
|
(let [cfg (assoc cfg ::type "management" ::metrics-id :rpc-management-timing)
|
||||||
(->> (sv/scan-ns
|
mods (cond->> (list 'app.rpc.management.exporter)
|
||||||
'app.rpc.management.nitrate
|
(contains? cf/flags :nitrate)
|
||||||
'app.rpc.management.exporter)
|
(cons 'app.rpc.management.nitrate))]
|
||||||
|
|
||||||
|
(->> (apply sv/scan-ns mods)
|
||||||
(map (partial process-method cfg "management" wrap-management))
|
(map (partial process-method cfg "management" wrap-management))
|
||||||
(into {}))))
|
(into {}))))
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
[app.common.types.profile :refer [schema:profile]]
|
[app.common.types.profile :refer [schema:profile]]
|
||||||
[app.common.types.team :refer [schema:team]]
|
[app.common.types.team :refer [schema:team]]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.msgbus :as mbus]
|
[app.msgbus :as mbus]
|
||||||
[app.rpc :as-alias rpc]
|
[app.rpc :as-alias rpc]
|
||||||
@ -26,6 +25,7 @@
|
|||||||
(sv/defmethod ::authenticate
|
(sv/defmethod ::authenticate
|
||||||
"Authenticate the current user"
|
"Authenticate the current user"
|
||||||
{::doc/added "2.14"
|
{::doc/added "2.14"
|
||||||
|
::sm/params [:map]
|
||||||
::sm/result schema:profile}
|
::sm/result schema:profile}
|
||||||
[cfg {:keys [::rpc/profile-id] :as params}]
|
[cfg {:keys [::rpc/profile-id] :as params}]
|
||||||
(let [profile (profile/get-profile cfg profile-id)]
|
(let [profile (profile/get-profile cfg profile-id)]
|
||||||
@ -51,12 +51,12 @@
|
|||||||
(sv/defmethod ::get-teams
|
(sv/defmethod ::get-teams
|
||||||
"List teams for which current user is owner"
|
"List teams for which current user is owner"
|
||||||
{::doc/added "2.14"
|
{::doc/added "2.14"
|
||||||
|
::sm/params [:map]
|
||||||
::sm/result schema:get-teams-result}
|
::sm/result schema:get-teams-result}
|
||||||
[cfg {:keys [::rpc/profile-id]}]
|
[cfg {:keys [::rpc/profile-id]}]
|
||||||
(when (contains? cf/flags :nitrate)
|
(let [current-user-id (-> (profile/get-profile cfg profile-id) :id)]
|
||||||
(let [current-user-id (-> (profile/get-profile cfg profile-id) :id)]
|
(->> (db/exec! cfg [sql:get-teams current-user-id])
|
||||||
(->> (db/exec! cfg [sql:get-teams current-user-id])
|
(map #(select-keys % [:id :name])))))
|
||||||
(map #(select-keys % [:id :name]))))))
|
|
||||||
|
|
||||||
;; ---- API: notify-team-change
|
;; ---- API: notify-team-change
|
||||||
|
|
||||||
@ -71,20 +71,12 @@
|
|||||||
::sm/params schema:notify-team-change
|
::sm/params schema:notify-team-change
|
||||||
::rpc/auth false}
|
::rpc/auth false}
|
||||||
[cfg {:keys [id organization-id organization-name]}]
|
[cfg {:keys [id organization-id organization-name]}]
|
||||||
(when (contains? cf/flags :nitrate)
|
(let [msgbus (::mbus/msgbus cfg)]
|
||||||
(let [msgbus (::mbus/msgbus cfg)]
|
(mbus/pub! msgbus
|
||||||
(mbus/pub! msgbus
|
;;TODO There is a bug on dashboard with teams notifications.
|
||||||
;;TODO There is a bug on dashboard with teams notifications.
|
;;For now we send it to uuid/zero instead of team-id
|
||||||
;;For now we send it to uuid/zero instead of team-id
|
:topic uuid/zero
|
||||||
:topic uuid/zero
|
:message {:type :team-org-change
|
||||||
:message {:type :team-org-change
|
:team-id id
|
||||||
:team-id id
|
:organization-id organization-id
|
||||||
:organization-id organization-id
|
:organization-name organization-name})))
|
||||||
:organization-name organization-name}))))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
;; FIXME: specify more fields
|
;; FIXME: specify more fields
|
||||||
(def schema:team
|
(def schema:team
|
||||||
[:map
|
[:map {:title "Team"}
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
[:name :string]])
|
[:name :string]])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user