mirror of
https://github.com/penpot/penpot.git
synced 2025-05-18 11:46:11 +02:00
✨ Fix all linter issues on backend code.
This commit is contained in:
parent
6881e3d795
commit
44a21de783
43 changed files with 219 additions and 304 deletions
|
@ -1,10 +1,17 @@
|
||||||
{:lint-as {potok.core/reify clojure.core/reify
|
{:lint-as {potok.core/reify clojure.core/reify
|
||||||
promesa.core/let clojure.core/let
|
promesa.core/let clojure.core/let
|
||||||
app.db/with-atomic clojure.core/with-open}
|
app.db/with-atomic clojure.core/with-open}
|
||||||
|
:output
|
||||||
|
{:exclude-files ["data_readers.clj"]}
|
||||||
|
|
||||||
:linters
|
:linters
|
||||||
{:unsorted-required-namespaces
|
{:unsorted-required-namespaces
|
||||||
{:level :warning}
|
{:level :warning}
|
||||||
|
|
||||||
|
:unresolved-namespace
|
||||||
|
{:level :warning
|
||||||
|
:exclude [data_readers]}
|
||||||
|
|
||||||
:single-key-in
|
:single-key-in
|
||||||
{:level :warning}
|
{:level :warning}
|
||||||
|
|
||||||
|
@ -16,6 +23,7 @@
|
||||||
:unresolved-symbol
|
:unresolved-symbol
|
||||||
{:exclude ['(app.services.mutations/defmutation)
|
{:exclude ['(app.services.mutations/defmutation)
|
||||||
'(app.services.queries/defquery)
|
'(app.services.queries/defquery)
|
||||||
|
'(app.util.dispatcher/defservice)
|
||||||
'(mount.core/defstate)
|
'(mount.core/defstate)
|
||||||
]}}}
|
]}}}
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,16 @@
|
||||||
(ns app.cli.fixtures
|
(ns app.cli.fixtures
|
||||||
"A initial fixtures."
|
"A initial fixtures."
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[mount.core :as mount]
|
|
||||||
[buddy.hashers :as hashers]
|
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.migrations]
|
[app.migrations]
|
||||||
[app.services.mutations.profile :as profile]
|
[app.services.mutations.profile :as profile]
|
||||||
[app.util.blob :as blob]))
|
[app.util.blob :as blob]
|
||||||
|
[buddy.hashers :as hashers]
|
||||||
|
[clojure.tools.logging :as log]
|
||||||
|
[mount.core :as mount]))
|
||||||
|
|
||||||
(defn- mk-uuid
|
(defn- mk-uuid
|
||||||
[prefix & args]
|
[prefix & args]
|
||||||
|
|
|
@ -5,27 +5,27 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2016-2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.cli.media-loader
|
(ns app.cli.media-loader
|
||||||
"Media libraries importer (command line helper)."
|
"Media libraries importer (command line helper)."
|
||||||
(:require
|
#_(:require
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[clojure.java.io :as io]
|
|
||||||
[mount.core :as mount]
|
|
||||||
[datoteka.core :as fs]
|
|
||||||
[app.config]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.db :as db]
|
|
||||||
[app.media]
|
|
||||||
[app.media-storage]
|
|
||||||
[app.migrations]
|
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.services.mutations.projects :as projects]
|
[app.config]
|
||||||
|
[app.db :as db]
|
||||||
|
[app.media-storage]
|
||||||
|
[app.media]
|
||||||
|
[app.migrations]
|
||||||
[app.services.mutations.files :as files]
|
[app.services.mutations.files :as files]
|
||||||
[app.services.mutations.media :as media])
|
[app.services.mutations.media :as media]
|
||||||
(:import
|
[app.services.mutations.projects :as projects]
|
||||||
|
[clojure.java.io :as io]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[clojure.tools.logging :as log]
|
||||||
|
[datoteka.core :as fs]
|
||||||
|
[mount.core :as mount])
|
||||||
|
#_(:import
|
||||||
java.io.PushbackReader))
|
java.io.PushbackReader))
|
||||||
|
|
||||||
;; --- Constants & Helpers
|
;; --- Constants & Helpers
|
||||||
|
|
|
@ -10,14 +10,12 @@
|
||||||
(ns app.config
|
(ns app.config
|
||||||
"A configuration management."
|
"A configuration management."
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.spec :as us]
|
||||||
|
[app.util.time :as dt]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[environ.core :refer [env]]
|
[environ.core :refer [env]]
|
||||||
[mount.core :refer [defstate]]
|
[mount.core :refer [defstate]]))
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.util.time :as dt]))
|
|
||||||
|
|
||||||
(def defaults
|
(def defaults
|
||||||
{:http-server-port 6060
|
{:http-server-port 6060
|
||||||
|
|
|
@ -13,19 +13,15 @@
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.metrics :as mtx]
|
[app.metrics :as mtx]
|
||||||
[app.util.data :as data]
|
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.util.transit :as t]
|
[app.util.transit :as t]
|
||||||
[clojure.data.json :as json]
|
[clojure.data.json :as json]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[lambdaisland.uri :refer [uri]]
|
|
||||||
[mount.core :as mount :refer [defstate]]
|
[mount.core :as mount :refer [defstate]]
|
||||||
[next.jdbc :as jdbc]
|
[next.jdbc :as jdbc]
|
||||||
[next.jdbc.date-time :as jdbc-dt]
|
[next.jdbc.date-time :as jdbc-dt]
|
||||||
[next.jdbc.optional :as jdbc-opt]
|
[next.jdbc.optional :as jdbc-opt]
|
||||||
[next.jdbc.result-set :as jdbc-rs]
|
|
||||||
[next.jdbc.sql :as jdbc-sql]
|
[next.jdbc.sql :as jdbc-sql]
|
||||||
[next.jdbc.sql.builder :as jdbc-bld])
|
[next.jdbc.sql.builder :as jdbc-bld])
|
||||||
(:import
|
(:import
|
||||||
|
@ -34,8 +30,8 @@
|
||||||
com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory
|
com.zaxxer.hikari.metrics.prometheus.PrometheusMetricsTrackerFactory
|
||||||
java.sql.Connection
|
java.sql.Connection
|
||||||
java.sql.Savepoint
|
java.sql.Savepoint
|
||||||
org.postgresql.jdbc.PgArray
|
|
||||||
org.postgresql.geometric.PGpoint
|
org.postgresql.geometric.PGpoint
|
||||||
|
org.postgresql.jdbc.PgArray
|
||||||
org.postgresql.util.PGInterval
|
org.postgresql.util.PGInterval
|
||||||
org.postgresql.util.PGobject))
|
org.postgresql.util.PGobject))
|
||||||
|
|
||||||
|
@ -83,6 +79,8 @@
|
||||||
(jdbc-dt/read-as-instant)
|
(jdbc-dt/read-as-instant)
|
||||||
(HikariDataSource. dsc)))
|
(HikariDataSource. dsc)))
|
||||||
|
|
||||||
|
(declare pool)
|
||||||
|
|
||||||
(defstate pool
|
(defstate pool
|
||||||
:start (create-pool cfg/config)
|
:start (create-pool cfg/config)
|
||||||
:stop (.close pool))
|
:stop (.close pool))
|
||||||
|
|
|
@ -10,14 +10,11 @@
|
||||||
(ns app.emails
|
(ns app.emails
|
||||||
"Main api for send emails."
|
"Main api for send emails."
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[promesa.core :as p]
|
|
||||||
[app.config :as cfg]
|
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.db :as db]
|
[app.config :as cfg]
|
||||||
[app.tasks :as tasks]
|
[app.tasks :as tasks]
|
||||||
[app.util.emails :as emails]))
|
[app.util.emails :as emails]
|
||||||
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
;; --- Defaults
|
;; --- Defaults
|
||||||
|
|
||||||
|
|
|
@ -9,23 +9,21 @@
|
||||||
|
|
||||||
(ns app.http
|
(ns app.http
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[mount.core :as mount :refer [defstate]]
|
|
||||||
[reitit.ring :as rring]
|
|
||||||
[ring.adapter.jetty9 :as jetty]
|
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.http.auth :as auth]
|
[app.http.auth :as auth]
|
||||||
[app.http.auth.gitlab :as gitlab]
|
[app.http.auth.gitlab :as gitlab]
|
||||||
[app.http.auth.google :as google]
|
[app.http.auth.google :as google]
|
||||||
[app.http.auth.ldap :as ldap]
|
[app.http.auth.ldap :as ldap]
|
||||||
[app.http.debug :as debug]
|
|
||||||
[app.http.errors :as errors]
|
[app.http.errors :as errors]
|
||||||
[app.http.handlers :as handlers]
|
[app.http.handlers :as handlers]
|
||||||
[app.http.middleware :as middleware]
|
[app.http.middleware :as middleware]
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[app.http.ws :as ws]
|
[app.http.ws :as ws]
|
||||||
[app.metrics :as mtx]
|
[app.metrics :as mtx]
|
||||||
[app.services.notifications :as usn]))
|
[clojure.tools.logging :as log]
|
||||||
|
[mount.core :as mount :refer [defstate]]
|
||||||
|
[reitit.ring :as rring]
|
||||||
|
[ring.adapter.jetty9 :as jetty]))
|
||||||
|
|
||||||
(defn- create-router
|
(defn- create-router
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -9,20 +9,18 @@
|
||||||
|
|
||||||
(ns app.http.auth
|
(ns app.http.auth
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[app.services.mutations :as sm]))
|
[app.services.mutations :as sm]))
|
||||||
|
|
||||||
(defn login-handler
|
(defn login-handler
|
||||||
[req]
|
[req]
|
||||||
(let [data (:body-params req)
|
(let [data (:body-params req)
|
||||||
uagent (get-in req [:headers "user-agent"])]
|
uagent (get-in req [:headers "user-agent"])
|
||||||
(let [profile (sm/handle (assoc data ::sm/type :login))
|
profile (sm/handle (assoc data ::sm/type :login))
|
||||||
id (session/create (:id profile) uagent)]
|
id (session/create (:id profile) uagent)]
|
||||||
{:status 200
|
{:status 200
|
||||||
:cookies (session/cookies id)
|
:cookies (session/cookies id)
|
||||||
:body profile})))
|
:body profile}))
|
||||||
|
|
||||||
(defn logout-handler
|
(defn logout-handler
|
||||||
[req]
|
[req]
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.tokens :as tokens]
|
[app.services.tokens :as tokens]
|
||||||
|
@ -21,7 +20,6 @@
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[lambdaisland.uri :as uri]))
|
[lambdaisland.uri :as uri]))
|
||||||
|
|
||||||
|
|
||||||
(def default-base-gitlab-uri "https://gitlab.com")
|
(def default-base-gitlab-uri "https://gitlab.com")
|
||||||
|
|
||||||
(def scope "read_user")
|
(def scope "read_user")
|
||||||
|
@ -100,7 +98,7 @@
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(defn auth
|
(defn auth
|
||||||
[req]
|
[_req]
|
||||||
(let [token (tokens/generate
|
(let [token (tokens/generate
|
||||||
{:iss :gitlab-oauth
|
{:iss :gitlab-oauth
|
||||||
:exp (dt/in-future "15m")})
|
:exp (dt/in-future "15m")})
|
||||||
|
@ -119,7 +117,7 @@
|
||||||
(defn callback
|
(defn callback
|
||||||
[req]
|
[req]
|
||||||
(let [token (get-in req [:params :state])
|
(let [token (get-in req [:params :state])
|
||||||
tdata (tokens/verify token {:iss :gitlab-oauth})
|
_ (tokens/verify token {:iss :gitlab-oauth})
|
||||||
info (some-> (get-in req [:params :code])
|
info (some-> (get-in req [:params :code])
|
||||||
(get-access-token)
|
(get-access-token)
|
||||||
(get-user-info))]
|
(get-user-info))]
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.tokens :as tokens]
|
[app.services.tokens :as tokens]
|
||||||
|
@ -84,9 +83,8 @@
|
||||||
nil))))
|
nil))))
|
||||||
|
|
||||||
(defn auth
|
(defn auth
|
||||||
[req]
|
[_req]
|
||||||
(let [token (tokens/generate {:iss :google-oauth
|
(let [token (tokens/generate {:iss :google-oauth :exp (dt/in-future "15m")})
|
||||||
:exp (dt/in-future "15m")})
|
|
||||||
params {:scope scope
|
params {:scope scope
|
||||||
:access_type "offline"
|
:access_type "offline"
|
||||||
:include_granted_scopes true
|
:include_granted_scopes true
|
||||||
|
@ -104,7 +102,7 @@
|
||||||
(defn callback
|
(defn callback
|
||||||
[req]
|
[req]
|
||||||
(let [token (get-in req [:params :state])
|
(let [token (get-in req [:params :state])
|
||||||
tdata (tokens/verify token {:iss :google-oauth})
|
_ (tokens/verify token {:iss :google-oauth})
|
||||||
info (some-> (get-in req [:params :code])
|
info (some-> (get-in req [:params :code])
|
||||||
(get-access-token)
|
(get-access-token)
|
||||||
(get-user-info))]
|
(get-user-info))]
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
|
;; 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/.
|
||||||
|
;;
|
||||||
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.http.auth.ldap
|
(ns app.http.auth.ldap
|
||||||
(:require
|
(:require
|
||||||
[clj-ldap.client :as client]
|
|
||||||
[clojure.set :as set]
|
|
||||||
[mount.core :refer [defstate]]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.services.mutations :as sm]
|
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[clojure.tools.logging :as log]))
|
[app.services.mutations :as sm]
|
||||||
|
[clj-ldap.client :as client]
|
||||||
|
[clojure.set :as set]
|
||||||
|
[clojure.string]
|
||||||
|
[clojure.tools.logging :as log]
|
||||||
|
[mount.core :refer [defstate]]))
|
||||||
|
|
||||||
(defn replace-several [s & {:as replacements}]
|
(defn replace-several [s & {:as replacements}]
|
||||||
(reduce-kv clojure.string/replace s replacements))
|
(reduce-kv clojure.string/replace s replacements))
|
||||||
|
|
||||||
|
(declare *ldap-pool)
|
||||||
|
|
||||||
(defstate *ldap-pool
|
(defstate *ldap-pool
|
||||||
:start (delay
|
:start (delay
|
||||||
(try
|
(try
|
||||||
|
|
|
@ -1,24 +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) 2019 Andrey Antukh <niwi@niwi.nz>
|
|
||||||
|
|
||||||
(ns app.http.debug
|
|
||||||
"Debug related handlers."
|
|
||||||
(:require
|
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[promesa.core :as p]
|
|
||||||
[app.http.errors :as errors]
|
|
||||||
[app.http.session :as session]
|
|
||||||
[app.common.uuid :as uuid]))
|
|
||||||
|
|
||||||
(defn emails-list
|
|
||||||
[req]
|
|
||||||
{:status 200
|
|
||||||
:body "Hello world\n"})
|
|
||||||
|
|
||||||
(defn email
|
|
||||||
[req]
|
|
||||||
{:status 200
|
|
||||||
:body "Hello world\n"})
|
|
|
@ -2,23 +2,24 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2016-2019 Andrey Antukh <niwi@niwi.nz>
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.http.errors
|
(ns app.http.errors
|
||||||
"A errors handling for the http server."
|
"A errors handling for the http server."
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]))
|
||||||
[app.metrics :as mtx]
|
|
||||||
[io.aviso.exception :as e]))
|
|
||||||
|
|
||||||
(defmulti handle-exception
|
(defmulti handle-exception
|
||||||
(fn [err & rest]
|
(fn [err & _rest]
|
||||||
(:type (ex-data err))))
|
(:type (ex-data err))))
|
||||||
|
|
||||||
|
|
||||||
(defmethod handle-exception :authorization
|
(defmethod handle-exception :authorization
|
||||||
[err req]
|
[err _]
|
||||||
{:status 403
|
{:status 403
|
||||||
:body (ex-data err)})
|
:body (ex-data err)})
|
||||||
|
|
||||||
|
@ -38,13 +39,13 @@
|
||||||
:body response})))
|
:body response})))
|
||||||
|
|
||||||
(defmethod handle-exception :ratelimit
|
(defmethod handle-exception :ratelimit
|
||||||
[err req]
|
[_ _]
|
||||||
{:status 429
|
{:status 429
|
||||||
:headers {"retry-after" 1000}
|
:headers {"retry-after" 1000}
|
||||||
:body ""})
|
:body ""})
|
||||||
|
|
||||||
(defmethod handle-exception :not-found
|
(defmethod handle-exception :not-found
|
||||||
[err req]
|
[err _]
|
||||||
(let [response (ex-data err)]
|
(let [response (ex-data err)]
|
||||||
{:status 404
|
{:status 404
|
||||||
:body response}))
|
:body response}))
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
(handle-exception (.getCause ^Throwable err) req))
|
(handle-exception (.getCause ^Throwable err) req))
|
||||||
|
|
||||||
(defmethod handle-exception :parse
|
(defmethod handle-exception :parse
|
||||||
[err req]
|
[err _]
|
||||||
{:status 400
|
{:status 400
|
||||||
:body {:type :parse
|
:body {:type :parse
|
||||||
:message (ex-message err)}})
|
:message (ex-message err)}})
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
(ns app.http.handlers
|
(ns app.http.handlers
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.emails :as emails]
|
|
||||||
[app.http.session :as session]
|
|
||||||
[app.services.init]
|
[app.services.init]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.queries :as sq]))
|
[app.services.queries :as sq]))
|
||||||
|
|
|
@ -5,20 +5,19 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.http.middleware
|
(ns app.http.middleware
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.logging :as log]
|
[app.common.exceptions :as ex]
|
||||||
|
[app.config :as cfg]
|
||||||
|
[app.metrics :as mtx]
|
||||||
|
[app.util.transit :as t]
|
||||||
[ring.middleware.cookies :refer [wrap-cookies]]
|
[ring.middleware.cookies :refer [wrap-cookies]]
|
||||||
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
|
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
|
||||||
[ring.middleware.multipart-params :refer [wrap-multipart-params]]
|
[ring.middleware.multipart-params :refer [wrap-multipart-params]]
|
||||||
[ring.middleware.params :refer [wrap-params]]
|
[ring.middleware.params :refer [wrap-params]]
|
||||||
[ring.middleware.resource :refer [wrap-resource]]
|
[ring.middleware.resource :refer [wrap-resource]]))
|
||||||
[app.metrics :as mtx]
|
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.config :as cfg]
|
|
||||||
[app.util.transit :as t]))
|
|
||||||
|
|
||||||
(defn- wrap-parse-request-body
|
(defn- wrap-parse-request-body
|
||||||
[handler]
|
[handler]
|
||||||
|
@ -126,13 +125,13 @@
|
||||||
|
|
||||||
(def development-cors
|
(def development-cors
|
||||||
{:name ::development-cors
|
{:name ::development-cors
|
||||||
:compile (fn [& args]
|
:compile (fn [& _args]
|
||||||
(when *assert*
|
(when *assert*
|
||||||
wrap-development-cors))})
|
wrap-development-cors))})
|
||||||
|
|
||||||
(def development-resources
|
(def development-resources
|
||||||
{:name ::development-resources
|
{:name ::development-resources
|
||||||
:compile (fn [& args]
|
:compile (fn [& _args]
|
||||||
(when *assert*
|
(when *assert*
|
||||||
#(wrap-resource % "public")))})
|
#(wrap-resource % "public")))})
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,14 @@
|
||||||
(ns app.http.ws
|
(ns app.http.ws
|
||||||
"Web Socket handlers"
|
"Web Socket handlers"
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[ring.adapter.jetty9 :as jetty]
|
|
||||||
[ring.middleware.cookies :refer [wrap-cookies]]
|
|
||||||
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
|
|
||||||
[ring.middleware.params :refer [wrap-params]]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.http.session :refer [wrap-session]]
|
[app.http.session :refer [wrap-session]]
|
||||||
[app.services.notifications :as nf]))
|
[app.services.notifications :as nf]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[ring.middleware.cookies :refer [wrap-cookies]]
|
||||||
|
[ring.middleware.keyword-params :refer [wrap-keyword-params]]
|
||||||
|
[ring.middleware.params :refer [wrap-params]]))
|
||||||
|
|
||||||
(s/def ::file-id ::us/uuid)
|
(s/def ::file-id ::us/uuid)
|
||||||
(s/def ::session-id ::us/uuid)
|
(s/def ::session-id ::us/uuid)
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
;; --- Entry point
|
;; --- Entry point
|
||||||
|
|
||||||
(defn run
|
(defn run
|
||||||
[params]
|
[_params]
|
||||||
(require 'app.config
|
(require 'app.config
|
||||||
'app.srepl.server
|
'app.srepl.server
|
||||||
'app.migrations
|
'app.migrations
|
||||||
|
@ -37,5 +37,5 @@
|
||||||
|
|
||||||
|
|
||||||
(defn -main
|
(defn -main
|
||||||
[& args]
|
[& _args]
|
||||||
(run {}))
|
(run {}))
|
||||||
|
|
|
@ -10,14 +10,11 @@
|
||||||
(ns app.media
|
(ns app.media
|
||||||
"Media postprocessing."
|
"Media postprocessing."
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.media :as cm]
|
[app.common.media :as cm]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.media-storage :as mst]
|
|
||||||
[app.util.http :as http]
|
[app.util.http :as http]
|
||||||
[app.util.storage :as ust]
|
|
||||||
[clojure.core.async :as a]
|
[clojure.core.async :as a]
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
@ -25,11 +22,12 @@
|
||||||
[mount.core :refer [defstate]])
|
[mount.core :refer [defstate]])
|
||||||
(:import
|
(:import
|
||||||
java.io.ByteArrayInputStream
|
java.io.ByteArrayInputStream
|
||||||
java.io.InputStream
|
|
||||||
java.util.concurrent.Semaphore
|
java.util.concurrent.Semaphore
|
||||||
org.im4java.core.ConvertCmd
|
org.im4java.core.ConvertCmd
|
||||||
org.im4java.core.Info
|
org.im4java.core.IMOperation
|
||||||
org.im4java.core.IMOperation))
|
org.im4java.core.Info))
|
||||||
|
|
||||||
|
(declare semaphore)
|
||||||
|
|
||||||
(defstate semaphore
|
(defstate semaphore
|
||||||
:start (Semaphore. (:image-process-max-threads cfg/config 1)))
|
:start (Semaphore. (:image-process-max-threads cfg/config 1)))
|
||||||
|
@ -73,7 +71,7 @@
|
||||||
;; http://www.imagemagick.org/Usage/thumbnails/
|
;; http://www.imagemagick.org/Usage/thumbnails/
|
||||||
|
|
||||||
(defn- generic-process
|
(defn- generic-process
|
||||||
[{:keys [input format quality operation] :as params}]
|
[{:keys [input format operation] :as params}]
|
||||||
(let [{:keys [path mtype]} input
|
(let [{:keys [path mtype]} input
|
||||||
format (or (cm/mtype->format mtype) format)
|
format (or (cm/mtype->format mtype) format)
|
||||||
ext (cm/format->extension format)
|
ext (cm/format->extension format)
|
||||||
|
|
|
@ -5,24 +5,25 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2017-2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.media-storage
|
(ns app.media-storage
|
||||||
"A media storage impl for app."
|
"A media storage impl for app."
|
||||||
(:require
|
(:require
|
||||||
[mount.core :refer [defstate]]
|
[app.config :refer [config]]
|
||||||
[clojure.java.io :as io]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[datoteka.core :as fs]
|
|
||||||
[app.util.storage :as ust]
|
[app.util.storage :as ust]
|
||||||
[app.config :refer [config]]))
|
[mount.core :refer [defstate]]))
|
||||||
|
|
||||||
;; --- State
|
;; --- State
|
||||||
|
|
||||||
|
(declare assets-storage)
|
||||||
|
|
||||||
(defstate assets-storage
|
(defstate assets-storage
|
||||||
:start (ust/create {:base-path (:assets-directory config)
|
:start (ust/create {:base-path (:assets-directory config)
|
||||||
:base-uri (:assets-uri config)}))
|
:base-uri (:assets-uri config)}))
|
||||||
|
|
||||||
|
(declare media-storage)
|
||||||
|
|
||||||
(defstate media-storage
|
(defstate media-storage
|
||||||
:start (ust/create {:base-path (:media-directory config)
|
:start (ust/create {:base-path (:media-directory config)
|
||||||
:base-uri (:media-uri config)
|
:base-uri (:media-uri config)
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
;; Copyright (c) 2020 UXBOX Labs SL
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.metrics
|
(ns app.metrics
|
||||||
(:require
|
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[cuerdas.core :as str])
|
|
||||||
(:import
|
(:import
|
||||||
io.prometheus.client.CollectorRegistry
|
io.prometheus.client.CollectorRegistry
|
||||||
io.prometheus.client.Counter
|
io.prometheus.client.Counter
|
||||||
|
@ -172,7 +169,7 @@
|
||||||
(assoc mdata ::summary-original original)))))))
|
(assoc mdata ::summary-original original)))))))
|
||||||
|
|
||||||
(defn dump
|
(defn dump
|
||||||
[& args]
|
[& _args]
|
||||||
(let [samples (.metricFamilySamples ^CollectorRegistry registry)
|
(let [samples (.metricFamilySamples ^CollectorRegistry registry)
|
||||||
writer (StringWriter.)]
|
writer (StringWriter.)]
|
||||||
(TextFormat/write004 writer samples)
|
(TextFormat/write004 writer samples)
|
||||||
|
|
|
@ -9,11 +9,10 @@
|
||||||
|
|
||||||
(ns app.migrations
|
(ns app.migrations
|
||||||
(:require
|
(:require
|
||||||
[mount.core :as mount :refer [defstate]]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.config :as cfg]
|
|
||||||
[app.migrations.migration-0023 :as mg0023]
|
[app.migrations.migration-0023 :as mg0023]
|
||||||
[app.util.migrations :as mg]))
|
[app.util.migrations :as mg]
|
||||||
|
[mount.core :as mount :refer [defstate]]))
|
||||||
|
|
||||||
(def +migrations+
|
(def +migrations+
|
||||||
{:name "uxbox-main"
|
{:name "uxbox-main"
|
||||||
|
|
|
@ -7,13 +7,9 @@
|
||||||
(ns app.redis
|
(ns app.redis
|
||||||
(:refer-clojure :exclude [run!])
|
(:refer-clojure :exclude [run!])
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[lambdaisland.uri :refer [uri]]
|
|
||||||
[mount.core :as mount :refer [defstate]]
|
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.util.data :as data]
|
[app.util.redis :as redis]
|
||||||
[app.util.redis :as redis])
|
[mount.core :as mount :refer [defstate]])
|
||||||
(:import
|
(:import
|
||||||
java.lang.AutoCloseable))
|
java.lang.AutoCloseable))
|
||||||
|
|
||||||
|
@ -24,10 +20,14 @@
|
||||||
(let [uri (:redis-uri config "redis://redis/0")]
|
(let [uri (:redis-uri config "redis://redis/0")]
|
||||||
(redis/client uri)))
|
(redis/client uri)))
|
||||||
|
|
||||||
|
(declare client)
|
||||||
|
|
||||||
(defstate client
|
(defstate client
|
||||||
:start (create-client cfg/config)
|
:start (create-client cfg/config)
|
||||||
:stop (.close ^AutoCloseable client))
|
:stop (.close ^AutoCloseable client))
|
||||||
|
|
||||||
|
(declare conn)
|
||||||
|
|
||||||
(defstate conn
|
(defstate conn
|
||||||
:start (redis/connect client)
|
:start (redis/connect client)
|
||||||
:stop (.close ^AutoCloseable conn))
|
:stop (.close ^AutoCloseable conn))
|
||||||
|
|
|
@ -10,13 +10,11 @@
|
||||||
(ns app.services.middleware
|
(ns app.services.middleware
|
||||||
"Common middleware for services."
|
"Common middleware for services."
|
||||||
(:require
|
(:require
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[expound.alpha :as expound]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.metrics :as mtx]))
|
[app.metrics :as mtx]
|
||||||
|
[clojure.spec.alpha :as s]
|
||||||
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
(defn wrap-spec
|
(defn wrap-spec
|
||||||
[handler]
|
[handler]
|
||||||
|
@ -45,7 +43,7 @@
|
||||||
|
|
||||||
(defn- get-prefix
|
(defn- get-prefix
|
||||||
[nsname]
|
[nsname]
|
||||||
(let [[a b c] (str/split nsname ".")]
|
(let [[_ _ c] (str/split nsname ".")]
|
||||||
c))
|
c))
|
||||||
|
|
||||||
(defn wrap-metrics
|
(defn wrap-metrics
|
||||||
|
|
|
@ -9,21 +9,15 @@
|
||||||
|
|
||||||
(ns app.services.mutations.comments
|
(ns app.services.mutations.comments
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.config :as cfg]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.queries.projects :as proj]
|
|
||||||
[app.services.queries.files :as files]
|
|
||||||
[app.services.queries.comments :as comments]
|
[app.services.queries.comments :as comments]
|
||||||
[app.tasks :as tasks]
|
[app.services.queries.files :as files]
|
||||||
[app.util.blob :as blob]
|
[app.util.blob :as blob]
|
||||||
[app.util.storage :as ust]
|
[app.util.time :as dt]
|
||||||
[app.util.transit :as t]
|
[clojure.spec.alpha :as s]))
|
||||||
[app.util.time :as dt]))
|
|
||||||
|
|
||||||
;; --- Mutation: Create Comment Thread
|
;; --- Mutation: Create Comment Thread
|
||||||
|
|
||||||
|
@ -66,14 +60,16 @@
|
||||||
:created-at now
|
:created-at now
|
||||||
:modified-at now
|
:modified-at now
|
||||||
:seqn seqn
|
:seqn seqn
|
||||||
:position (db/pgpoint position)})
|
:position (db/pgpoint position)})]
|
||||||
|
|
||||||
|
|
||||||
;; Create a comment entry
|
;; Create a comment entry
|
||||||
comment (db/insert! conn :comment
|
(db/insert! conn :comment
|
||||||
{:thread-id (:id thread)
|
{:thread-id (:id thread)
|
||||||
:owner-id profile-id
|
:owner-id profile-id
|
||||||
:created-at now
|
:created-at now
|
||||||
:modified-at now
|
:modified-at now
|
||||||
:content content})]
|
:content content})
|
||||||
|
|
||||||
;; Make the current thread as read.
|
;; Make the current thread as read.
|
||||||
(upsert-comment-thread-status! conn profile-id (:id thread))
|
(upsert-comment-thread-status! conn profile-id (:id thread))
|
||||||
|
|
|
@ -10,17 +10,14 @@
|
||||||
(ns app.services.mutations.demo
|
(ns app.services.mutations.demo
|
||||||
"A demo specific mutations."
|
"A demo specific mutations."
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
[app.common.uuid :as uuid]
|
||||||
[buddy.core.codecs :as bc]
|
|
||||||
[buddy.core.nonce :as bn]
|
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.mutations.profile :as profile]
|
[app.services.mutations.profile :as profile]
|
||||||
[app.tasks :as tasks]
|
[app.tasks :as tasks]
|
||||||
[app.common.uuid :as uuid]
|
[buddy.core.codecs :as bc]
|
||||||
[app.util.time :as tm]))
|
[buddy.core.nonce :as bn]))
|
||||||
|
|
||||||
(sm/defmutation ::create-demo-profile
|
(sm/defmutation ::create-demo-profile
|
||||||
[_]
|
[_]
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
|
|
||||||
(ns app.services.mutations.files
|
(ns app.services.mutations.files
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[datoteka.core :as fs]
|
|
||||||
[promesa.core :as p]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages-migrations :as pmg]
|
[app.common.pages-migrations :as pmg]
|
||||||
|
@ -21,13 +18,13 @@
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.redis :as redis]
|
[app.redis :as redis]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.queries.projects :as proj]
|
|
||||||
[app.services.queries.files :as files]
|
[app.services.queries.files :as files]
|
||||||
|
[app.services.queries.projects :as proj]
|
||||||
[app.tasks :as tasks]
|
[app.tasks :as tasks]
|
||||||
[app.util.blob :as blob]
|
[app.util.blob :as blob]
|
||||||
[app.util.storage :as ust]
|
[app.util.time :as dt]
|
||||||
[app.util.transit :as t]
|
[app.util.transit :as t]
|
||||||
[app.util.time :as dt]))
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
;; --- Helpers & Specs
|
;; --- Helpers & Specs
|
||||||
|
|
||||||
|
@ -62,7 +59,7 @@
|
||||||
:can-edit true}))
|
:can-edit true}))
|
||||||
|
|
||||||
(defn create-file
|
(defn create-file
|
||||||
[conn {:keys [id profile-id name project-id is-shared]
|
[conn {:keys [id name project-id is-shared]
|
||||||
:or {is-shared false}
|
:or {is-shared false}
|
||||||
:as params}]
|
:as params}]
|
||||||
(let [id (or id (uuid/next))
|
(let [id (or id (uuid/next))
|
||||||
|
@ -286,7 +283,7 @@
|
||||||
(assoc :changes (blob/encode changes)
|
(assoc :changes (blob/encode changes)
|
||||||
:session-id sid))
|
:session-id sid))
|
||||||
|
|
||||||
chng (insert-change conn file)
|
_ (insert-change conn file)
|
||||||
msg {:type :file-change
|
msg {:type :file-change
|
||||||
:profile-id (:profile-id params)
|
:profile-id (:profile-id params)
|
||||||
:file-id (:id file)
|
:file-id (:id file)
|
||||||
|
@ -319,7 +316,7 @@
|
||||||
:data (:data file)}
|
:data (:data file)}
|
||||||
{:id (:id file)})
|
{:id (:id file)})
|
||||||
|
|
||||||
(retrieve-lagged-changes conn chng params)))
|
(retrieve-lagged-changes conn params)))
|
||||||
|
|
||||||
(defn- insert-change
|
(defn- insert-change
|
||||||
[conn {:keys [revn data changes session-id] :as file}]
|
[conn {:keys [revn data changes session-id] :as file}]
|
||||||
|
@ -343,7 +340,7 @@
|
||||||
order by s.created_at asc")
|
order by s.created_at asc")
|
||||||
|
|
||||||
(defn- retrieve-lagged-changes
|
(defn- retrieve-lagged-changes
|
||||||
[conn snapshot params]
|
[conn params]
|
||||||
(->> (db/exec! conn [sql:lagged-changes (:id params) (:revn params)])
|
(->> (db/exec! conn [sql:lagged-changes (:id params) (:revn params)])
|
||||||
(mapv files/decode-row)))
|
(mapv files/decode-row)))
|
||||||
|
|
||||||
|
|
|
@ -9,21 +9,18 @@
|
||||||
|
|
||||||
(ns app.services.mutations.media
|
(ns app.services.mutations.media
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[datoteka.core :as fs]
|
|
||||||
[app.common.media :as cm]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
|
[app.common.media :as cm]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.media :as media]
|
[app.media :as media]
|
||||||
|
[app.media-storage :as mst]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.queries.teams :as teams]
|
[app.services.queries.teams :as teams]
|
||||||
[app.tasks :as tasks]
|
|
||||||
[app.media-storage :as mst]
|
|
||||||
[app.util.storage :as ust]
|
[app.util.storage :as ust]
|
||||||
[app.util.time :as dt]))
|
[clojure.spec.alpha :as s]
|
||||||
|
[datoteka.core :as fs]))
|
||||||
|
|
||||||
(def thumbnail-options
|
(def thumbnail-options
|
||||||
{:width 100
|
{:width 100
|
||||||
|
|
|
@ -10,24 +10,20 @@
|
||||||
(ns app.services.mutations.profile
|
(ns app.services.mutations.profile
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.media :as cm]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.emails :as emails]
|
[app.emails :as emails]
|
||||||
[app.media :as media]
|
|
||||||
[app.media-storage :as mst]
|
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
|
[app.media :as media]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.mutations.projects :as projects]
|
[app.services.mutations.projects :as projects]
|
||||||
[app.services.mutations.teams :as teams]
|
[app.services.mutations.teams :as teams]
|
||||||
|
[app.services.mutations.verify-token :refer [process-token]]
|
||||||
[app.services.queries.profile :as profile]
|
[app.services.queries.profile :as profile]
|
||||||
[app.services.tokens :as tokens]
|
[app.services.tokens :as tokens]
|
||||||
[app.services.mutations.verify-token :refer [process-token]]
|
|
||||||
[app.tasks :as tasks]
|
[app.tasks :as tasks]
|
||||||
[app.util.blob :as blob]
|
|
||||||
[app.util.storage :as ust]
|
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[buddy.hashers :as hashers]
|
[buddy.hashers :as hashers]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
|
@ -361,7 +357,7 @@
|
||||||
|
|
||||||
(sm/defmutation ::request-profile-recovery
|
(sm/defmutation ::request-profile-recovery
|
||||||
[{:keys [email] :as params}]
|
[{:keys [email] :as params}]
|
||||||
(letfn [(create-recovery-token [conn {:keys [id] :as profile}]
|
(letfn [(create-recovery-token [{:keys [id] :as profile}]
|
||||||
(let [token (tokens/generate
|
(let [token (tokens/generate
|
||||||
{:iss :password-recovery
|
{:iss :password-recovery
|
||||||
:exp (dt/in-future "15m")
|
:exp (dt/in-future "15m")
|
||||||
|
@ -377,7 +373,7 @@
|
||||||
(db/with-atomic [conn db/pool]
|
(db/with-atomic [conn db/pool]
|
||||||
(some->> email
|
(some->> email
|
||||||
(profile/retrieve-profile-data-by-email conn)
|
(profile/retrieve-profile-data-by-email conn)
|
||||||
(create-recovery-token conn)
|
(create-recovery-token)
|
||||||
(send-email-notification conn))
|
(send-email-notification conn))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
@ -390,7 +386,7 @@
|
||||||
|
|
||||||
(sm/defmutation ::recover-profile
|
(sm/defmutation ::recover-profile
|
||||||
[{:keys [token password]}]
|
[{:keys [token password]}]
|
||||||
(letfn [(validate-token [conn token]
|
(letfn [(validate-token [token]
|
||||||
(let [tdata (tokens/verify token {:iss :password-recovery})]
|
(let [tdata (tokens/verify token {:iss :password-recovery})]
|
||||||
(:profile-id tdata)))
|
(:profile-id tdata)))
|
||||||
|
|
||||||
|
@ -399,7 +395,7 @@
|
||||||
(db/update! conn :profile {:password pwd} {:id profile-id})))]
|
(db/update! conn :profile {:password pwd} {:id profile-id})))]
|
||||||
|
|
||||||
(db/with-atomic [conn db/pool]
|
(db/with-atomic [conn db/pool]
|
||||||
(->> (validate-token conn token)
|
(->> (validate-token token)
|
||||||
(update-password conn))
|
(update-password conn))
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,10 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.services.mutations.projects
|
(ns app.services.mutations.projects
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
|
@ -18,7 +16,7 @@
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.queries.projects :as proj]
|
[app.services.queries.projects :as proj]
|
||||||
[app.tasks :as tasks]
|
[app.tasks :as tasks]
|
||||||
[app.util.blob :as blob]))
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
;; --- Helpers & Specs
|
;; --- Helpers & Specs
|
||||||
|
|
||||||
|
@ -48,7 +46,7 @@
|
||||||
(assoc proj :is-pinned true))))
|
(assoc proj :is-pinned true))))
|
||||||
|
|
||||||
(defn create-project
|
(defn create-project
|
||||||
[conn {:keys [id profile-id team-id name default?] :as params}]
|
[conn {:keys [id team-id name default?] :as params}]
|
||||||
(let [id (or id (uuid/next))
|
(let [id (or id (uuid/next))
|
||||||
default? (if (boolean? default?) default? false)]
|
default? (if (boolean? default?) default? false)]
|
||||||
(db/insert! conn :project
|
(db/insert! conn :project
|
||||||
|
@ -107,11 +105,10 @@
|
||||||
(sm/defmutation ::rename-project
|
(sm/defmutation ::rename-project
|
||||||
[{:keys [id profile-id name] :as params}]
|
[{:keys [id profile-id name] :as params}]
|
||||||
(db/with-atomic [conn db/pool]
|
(db/with-atomic [conn db/pool]
|
||||||
(let [project (db/get-by-id conn :project id {:for-update true})]
|
|
||||||
(proj/check-edition-permissions! conn profile-id id)
|
(proj/check-edition-permissions! conn profile-id id)
|
||||||
(db/update! conn :project
|
(db/update! conn :project
|
||||||
{:name name}
|
{:name name}
|
||||||
{:id id}))))
|
{:id id})))
|
||||||
|
|
||||||
;; --- Mutation: Delete Project
|
;; --- Mutation: Delete Project
|
||||||
|
|
||||||
|
@ -139,6 +136,6 @@
|
||||||
returning id")
|
returning id")
|
||||||
|
|
||||||
(defn mark-project-deleted
|
(defn mark-project-deleted
|
||||||
[conn {:keys [id profile-id] :as params}]
|
[conn {:keys [id] :as params}]
|
||||||
(db/exec! conn [sql:mark-project-deleted id])
|
(db/exec! conn [sql:mark-project-deleted id])
|
||||||
nil)
|
nil)
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
[app.media-storage :as mst]
|
[app.media-storage :as mst]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.mutations.projects :as projects]
|
[app.services.mutations.projects :as projects]
|
||||||
|
[app.services.queries.profile :as profile]
|
||||||
[app.services.queries.teams :as teams]
|
[app.services.queries.teams :as teams]
|
||||||
[app.services.tokens :as tokens]
|
[app.services.tokens :as tokens]
|
||||||
[app.services.queries.profile :as profile]
|
|
||||||
[app.tasks :as tasks]
|
[app.tasks :as tasks]
|
||||||
[app.util.storage :as ust]
|
[app.util.storage :as ust]
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
|
@ -58,7 +58,7 @@
|
||||||
team)))
|
team)))
|
||||||
|
|
||||||
(defn create-team
|
(defn create-team
|
||||||
[conn {:keys [id profile-id name default?] :as params}]
|
[conn {:keys [id name default?] :as params}]
|
||||||
(let [id (or id (uuid/next))
|
(let [id (or id (uuid/next))
|
||||||
default? (if (boolean? default?) default? false)]
|
default? (if (boolean? default?) default? false)]
|
||||||
(db/insert! conn :team
|
(db/insert! conn :team
|
||||||
|
@ -268,7 +268,7 @@
|
||||||
(assoc team :photo (str photo)))))
|
(assoc team :photo (str photo)))))
|
||||||
|
|
||||||
(defn upload-photo
|
(defn upload-photo
|
||||||
[conn {:keys [file profile-id]}]
|
[_conn {:keys [file]}]
|
||||||
(let [prefix (-> (bn/random-bytes 8)
|
(let [prefix (-> (bn/random-bytes 8)
|
||||||
(bc/bytes->b64u)
|
(bc/bytes->b64u)
|
||||||
(bc/bytes->str))
|
(bc/bytes->str))
|
||||||
|
|
|
@ -10,28 +10,16 @@
|
||||||
(ns app.services.mutations.verify-token
|
(ns app.services.mutations.verify-token
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.media :as cm]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.config :as cfg]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.emails :as emails]
|
|
||||||
[app.http.session :as session]
|
[app.http.session :as session]
|
||||||
[app.media :as media]
|
|
||||||
[app.media-storage :as mst]
|
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.mutations.teams :as teams]
|
[app.services.mutations.teams :as teams]
|
||||||
[app.services.queries.profile :as profile]
|
[app.services.queries.profile :as profile]
|
||||||
[app.services.tokens :as tokens]
|
[app.services.tokens :as tokens]
|
||||||
[app.tasks :as tasks]
|
[clojure.spec.alpha :as s]))
|
||||||
[app.util.blob :as blob]
|
|
||||||
[app.util.storage :as ust]
|
|
||||||
[app.util.time :as dt]
|
|
||||||
[buddy.hashers :as hashers]
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[cuerdas.core :as str]))
|
|
||||||
|
|
||||||
(defmulti process-token (fn [conn params claims] (:iss claims)))
|
(defmulti process-token (fn [_ _ claims] (:iss claims)))
|
||||||
|
|
||||||
(s/def ::verify-token
|
(s/def ::verify-token
|
||||||
(s/keys :req-un [::token]
|
(s/keys :req-un [::token]
|
||||||
|
@ -44,18 +32,17 @@
|
||||||
(process-token conn params claims))))
|
(process-token conn params claims))))
|
||||||
|
|
||||||
(defmethod process-token :change-email
|
(defmethod process-token :change-email
|
||||||
[conn params {:keys [profile-id email] :as claims}]
|
[conn _params {:keys [profile-id email] :as claims}]
|
||||||
(let [profile (db/get-by-id conn :profile profile-id {:for-update true})]
|
|
||||||
(when (profile/retrieve-profile-data-by-email conn email)
|
(when (profile/retrieve-profile-data-by-email conn email)
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :email-already-exists))
|
:code :email-already-exists))
|
||||||
(db/update! conn :profile
|
(db/update! conn :profile
|
||||||
{:email email}
|
{:email email}
|
||||||
{:id profile-id})
|
{:id profile-id})
|
||||||
claims))
|
claims)
|
||||||
|
|
||||||
(defmethod process-token :verify-email
|
(defmethod process-token :verify-email
|
||||||
[conn params {:keys [profile-id] :as claims}]
|
[conn _params {:keys [profile-id] :as claims}]
|
||||||
(let [profile (db/get-by-id conn :profile profile-id {:for-update true})]
|
(let [profile (db/get-by-id conn :profile profile-id {:for-update true})]
|
||||||
(when (:is-active profile)
|
(when (:is-active profile)
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
|
@ -71,7 +58,7 @@
|
||||||
claims))
|
claims))
|
||||||
|
|
||||||
(defmethod process-token :auth
|
(defmethod process-token :auth
|
||||||
[conn params {:keys [profile-id] :as claims}]
|
[conn _params {:keys [profile-id] :as claims}]
|
||||||
(let [profile (profile/retrieve-profile conn profile-id)]
|
(let [profile (profile/retrieve-profile conn profile-id)]
|
||||||
(assoc claims :profile profile)))
|
(assoc claims :profile profile)))
|
||||||
|
|
||||||
|
@ -137,7 +124,7 @@
|
||||||
;; --- Default
|
;; --- Default
|
||||||
|
|
||||||
(defmethod process-token :default
|
(defmethod process-token :default
|
||||||
[conn params claims]
|
[_ _ _]
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :invalid-token))
|
:code :invalid-token))
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,7 @@
|
||||||
|
|
||||||
(ns app.services.mutations.viewer
|
(ns app.services.mutations.viewer
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.pages :as cp]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.config :as cfg]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.services.mutations :as sm]
|
[app.services.mutations :as sm]
|
||||||
[app.services.queries.files :as files]
|
[app.services.queries.files :as files]
|
||||||
|
|
|
@ -10,17 +10,13 @@
|
||||||
(ns app.services.notifications
|
(ns app.services.notifications
|
||||||
"A websocket based notifications mechanism."
|
"A websocket based notifications mechanism."
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.metrics :as mtx]
|
[app.metrics :as mtx]
|
||||||
[app.redis :as redis]
|
[app.redis :as redis]
|
||||||
[app.util.async :as aa]
|
[app.util.async :as aa]
|
||||||
[app.util.time :as dt]
|
|
||||||
[app.util.transit :as t]
|
[app.util.transit :as t]
|
||||||
[clojure.core.async :as a]
|
[clojure.core.async :as a]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[promesa.core :as p]
|
|
||||||
[ring.adapter.jetty9 :as jetty]))
|
[ring.adapter.jetty9 :as jetty]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -40,7 +36,7 @@
|
||||||
:help "A total number of messages handled by the notifications service."}))
|
:help "A total number of messages handled by the notifications service."}))
|
||||||
|
|
||||||
(defn websocket
|
(defn websocket
|
||||||
[{:keys [file-id team-id profile-id] :as params}]
|
[{:keys [file-id team-id] :as params}]
|
||||||
(let [in (a/chan 32)
|
(let [in (a/chan 32)
|
||||||
out (a/chan 32)]
|
out (a/chan 32)]
|
||||||
{:on-connect
|
{:on-connect
|
||||||
|
@ -62,18 +58,18 @@
|
||||||
(a/close! sub))))
|
(a/close! sub))))
|
||||||
|
|
||||||
:on-error
|
:on-error
|
||||||
(fn [conn e]
|
(fn [_conn _e]
|
||||||
(a/close! out)
|
(a/close! out)
|
||||||
(a/close! in))
|
(a/close! in))
|
||||||
|
|
||||||
:on-close
|
:on-close
|
||||||
(fn [conn status-code reason]
|
(fn [_conn _status _reason]
|
||||||
(metrics-active-connections :dec)
|
(metrics-active-connections :dec)
|
||||||
(a/close! out)
|
(a/close! out)
|
||||||
(a/close! in))
|
(a/close! in))
|
||||||
|
|
||||||
:on-text
|
:on-text
|
||||||
(fn [ws message]
|
(fn [_ws message]
|
||||||
(metrics-message-counter :inc)
|
(metrics-message-counter :inc)
|
||||||
(let [message (t/decode-str message)]
|
(let [message (t/decode-str message)]
|
||||||
(a/>!! in message)))
|
(a/>!! in message)))
|
||||||
|
@ -165,8 +161,7 @@
|
||||||
(defn- update-presence
|
(defn- update-presence
|
||||||
[file-id session-id profile-id]
|
[file-id session-id profile-id]
|
||||||
(aa/thread-try
|
(aa/thread-try
|
||||||
(let [now (dt/now)
|
(let [sql [sql:update-presence file-id session-id profile-id]]
|
||||||
sql [sql:update-presence file-id session-id profile-id]]
|
|
||||||
(db/exec-one! db/pool sql))))
|
(db/exec-one! db/pool sql))))
|
||||||
|
|
||||||
(defn- delete-presence
|
(defn- delete-presence
|
||||||
|
@ -177,13 +172,13 @@
|
||||||
:session-id session-id})))
|
:session-id session-id})))
|
||||||
|
|
||||||
(defmulti handle-message
|
(defmulti handle-message
|
||||||
(fn [ws message] (:type message)))
|
(fn [_ message] (:type message)))
|
||||||
|
|
||||||
;; TODO: check permissions for join a file-id channel (probably using
|
;; TODO: check permissions for join a file-id channel (probably using
|
||||||
;; single use token for avoid explicit database query).
|
;; single use token for avoid explicit database query).
|
||||||
|
|
||||||
(defmethod handle-message :connect
|
(defmethod handle-message :connect
|
||||||
[{:keys [file-id profile-id session-id output] :as ws} message]
|
[{:keys [file-id profile-id session-id] :as ws} _message]
|
||||||
(log/debugf "profile '%s' is connected to file '%s'" profile-id file-id)
|
(log/debugf "profile '%s' is connected to file '%s'" profile-id file-id)
|
||||||
(aa/go-try
|
(aa/go-try
|
||||||
(aa/<? (update-presence file-id session-id profile-id))
|
(aa/<? (update-presence file-id session-id profile-id))
|
||||||
|
@ -191,7 +186,7 @@
|
||||||
(aa/<? (publish file-id {:type :presence :sessions members})))))
|
(aa/<? (publish file-id {:type :presence :sessions members})))))
|
||||||
|
|
||||||
(defmethod handle-message :disconnect
|
(defmethod handle-message :disconnect
|
||||||
[{:keys [profile-id file-id session-id] :as ws} message]
|
[{:keys [profile-id file-id session-id] :as ws} _message]
|
||||||
(log/debugf "profile '%s' is disconnected from '%s'" profile-id file-id)
|
(log/debugf "profile '%s' is disconnected from '%s'" profile-id file-id)
|
||||||
(aa/go-try
|
(aa/go-try
|
||||||
(aa/<? (delete-presence file-id session-id profile-id))
|
(aa/<? (delete-presence file-id session-id profile-id))
|
||||||
|
@ -199,7 +194,7 @@
|
||||||
(aa/<? (publish file-id {:type :presence :sessions members})))))
|
(aa/<? (publish file-id {:type :presence :sessions members})))))
|
||||||
|
|
||||||
(defmethod handle-message :keepalive
|
(defmethod handle-message :keepalive
|
||||||
[{:keys [profile-id file-id session-id] :as ws} message]
|
[{:keys [profile-id file-id session-id] :as ws} _message]
|
||||||
(update-presence file-id session-id profile-id))
|
(update-presence file-id session-id profile-id))
|
||||||
|
|
||||||
(defmethod handle-message :pointer-update
|
(defmethod handle-message :pointer-update
|
||||||
|
@ -210,6 +205,6 @@
|
||||||
(publish file-id message)))
|
(publish file-id message)))
|
||||||
|
|
||||||
(defmethod handle-message :default
|
(defmethod handle-message :default
|
||||||
[ws message]
|
[_ws message]
|
||||||
(a/go
|
(a/go
|
||||||
(log/warnf "received unexpected message: " message)))
|
(log/warnf "received unexpected message: %s" message)))
|
||||||
|
|
|
@ -9,19 +9,12 @@
|
||||||
|
|
||||||
(ns app.services.queries.comments
|
(ns app.services.queries.comments
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.config :as cfg]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.services.queries :as sq]
|
[app.services.queries :as sq]
|
||||||
[app.services.queries.files :as files]
|
[app.services.queries.files :as files]
|
||||||
[app.services.queries.teams :as teams]
|
[app.services.queries.teams :as teams]
|
||||||
[app.util.time :as dt]
|
[clojure.spec.alpha :as s]))
|
||||||
[app.util.transit :as t]
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[datoteka.core :as fs]
|
|
||||||
[promesa.core :as p]))
|
|
||||||
|
|
||||||
(defn decode-row
|
(defn decode-row
|
||||||
[{:keys [participants position] :as row}]
|
[{:keys [participants position] :as row}]
|
||||||
|
@ -70,7 +63,7 @@
|
||||||
window w as (partition by c.thread_id order by c.created_at asc)")
|
window w as (partition by c.thread_id order by c.created_at asc)")
|
||||||
|
|
||||||
(defn- retrieve-comment-threads
|
(defn- retrieve-comment-threads
|
||||||
[conn {:keys [profile-id file-id team-id]}]
|
[conn {:keys [profile-id file-id]}]
|
||||||
(files/check-read-permissions! conn profile-id file-id)
|
(files/check-read-permissions! conn profile-id file-id)
|
||||||
(->> (db/exec! conn [sql:comment-threads profile-id file-id])
|
(->> (db/exec! conn [sql:comment-threads profile-id file-id])
|
||||||
(into [] (map decode-row))))
|
(into [] (map decode-row))))
|
||||||
|
|
|
@ -5,20 +5,18 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.services.queries.files
|
(ns app.services.queries.files
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[promesa.core :as p]
|
|
||||||
[app.common.pages-migrations :as pmg]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
|
[app.common.pages-migrations :as pmg]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.media :as media]
|
|
||||||
[app.services.queries :as sq]
|
[app.services.queries :as sq]
|
||||||
[app.services.queries.projects :as projects]
|
[app.services.queries.projects :as projects]
|
||||||
[app.util.blob :as blob]))
|
[app.util.blob :as blob]
|
||||||
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
(declare decode-row)
|
(declare decode-row)
|
||||||
(declare decode-row-xf)
|
(declare decode-row-xf)
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
|
|
||||||
(ns app.services.queries.projects
|
(ns app.services.queries.projects
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
|
[app.common.spec :as us]
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.services.queries :as sq]
|
[app.services.queries :as sq]
|
||||||
[app.services.queries.teams :as teams]))
|
[app.services.queries.teams :as teams]
|
||||||
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
;; --- Check Project Permissions
|
;; --- Check Project Permissions
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,16 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2019-2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.services.queries.recent-files
|
(ns app.services.queries.recent-files
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[promesa.core :as p]
|
|
||||||
[app.db :as db]
|
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
|
[app.db :as db]
|
||||||
[app.services.queries :as sq]
|
[app.services.queries :as sq]
|
||||||
|
[app.services.queries.files :refer [decode-row-xf]]
|
||||||
[app.services.queries.teams :as teams]
|
[app.services.queries.teams :as teams]
|
||||||
[app.services.queries.projects :as projects :refer [retrieve-projects]]
|
[clojure.spec.alpha :as s]))
|
||||||
[app.services.queries.files :refer [decode-row-xf]]))
|
|
||||||
|
|
||||||
(def sql:recent-files
|
(def sql:recent-files
|
||||||
"with recent_files as (
|
"with recent_files as (
|
||||||
|
|
|
@ -5,18 +5,16 @@
|
||||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; defined by the Mozilla Public License, v. 2.0.
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2020 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.services.queries.teams
|
(ns app.services.queries.teams
|
||||||
(:require
|
(:require
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.services.queries :as sq]
|
[app.services.queries :as sq]
|
||||||
[app.services.queries.profile :as profile]
|
[app.services.queries.profile :as profile]
|
||||||
[app.util.blob :as blob]))
|
[clojure.spec.alpha :as s]))
|
||||||
|
|
||||||
;; --- Team Edition Permissions
|
;; --- Team Edition Permissions
|
||||||
|
|
||||||
|
|
|
@ -10,16 +10,11 @@
|
||||||
(ns app.services.tokens
|
(ns app.services.tokens
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.spec :as us]
|
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.db :as db]
|
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
[app.util.transit :as t]
|
[app.util.transit :as t]
|
||||||
[buddy.core.codecs :as bc]
|
|
||||||
[buddy.core.kdf :as bk]
|
[buddy.core.kdf :as bk]
|
||||||
[buddy.core.nonce :as bn]
|
|
||||||
[buddy.sign.jwe :as jwe]
|
[buddy.sign.jwe :as jwe]
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[clojure.tools.logging :as log]))
|
[clojure.tools.logging :as log]))
|
||||||
|
|
||||||
(defn- derive-tokens-secret
|
(defn- derive-tokens-secret
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns app.srepl.main
|
(ns app.srepl.main
|
||||||
"A main namespace for server repl."
|
"A main namespace for server repl."
|
||||||
|
#_:clj-kondo/ignore
|
||||||
(:require
|
(:require
|
||||||
[clojure.pprint :refer [pprint]]
|
[clojure.pprint :refer [pprint]]
|
||||||
[app.db :as db]))
|
[app.db :as db]))
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
|
;; 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/.
|
||||||
|
;;
|
||||||
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.srepl.server
|
(ns app.srepl.server
|
||||||
"Server Repl."
|
"Server Repl."
|
||||||
(:require
|
(:require
|
||||||
[clojure.pprint :refer [pprint]]
|
|
||||||
[clojure.main :as cm]
|
|
||||||
[clojure.core.server :as ccs]
|
|
||||||
[app.srepl.main]
|
[app.srepl.main]
|
||||||
|
[clojure.core.server :as ccs]
|
||||||
|
[clojure.main :as cm]
|
||||||
[mount.core :as mount :refer [defstate]]))
|
[mount.core :as mount :refer [defstate]]))
|
||||||
|
|
||||||
(defn- repl-init
|
(defn- repl-init
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cfg]
|
|
||||||
[app.db :as db]
|
[app.db :as db]
|
||||||
[app.metrics :as mtx]
|
[app.metrics :as mtx]
|
||||||
[app.util.time :as dt]
|
[app.util.time :as dt]
|
||||||
|
|
|
@ -68,8 +68,7 @@
|
||||||
])
|
])
|
||||||
|
|
||||||
(defstate executor
|
(defstate executor
|
||||||
:start (thread-pool {:idle-timeout 10000
|
:start (thread-pool {:min-threads 0
|
||||||
:min-threads 0
|
|
||||||
:max-threads 256})
|
:max-threads 256})
|
||||||
:stop (stop! executor))
|
:stop (stop! executor))
|
||||||
|
|
||||||
|
@ -381,7 +380,7 @@
|
||||||
(defn thread-pool
|
(defn thread-pool
|
||||||
([] (thread-pool {}))
|
([] (thread-pool {}))
|
||||||
([{:keys [min-threads max-threads name]
|
([{:keys [min-threads max-threads name]
|
||||||
:or {min-threads 0 max-threads 128 idle-timeout 60000}}]
|
:or {min-threads 0 max-threads 128}}]
|
||||||
(let [executor (QueuedThreadPool. max-threads min-threads)]
|
(let [executor (QueuedThreadPool. max-threads min-threads)]
|
||||||
(.setName executor (or name "default-tp"))
|
(.setName executor (or name "default-tp"))
|
||||||
(.start executor)
|
(.start executor)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue