193 server handler added

This commit is contained in:
Ivan Grishaev 2017-12-27 18:20:24 +03:00
parent 0eba6fed2e
commit e44639ae85
2 changed files with 18 additions and 0 deletions

View File

@ -90,3 +90,11 @@
(sql-value [value] (to-pg-json value)) (sql-value [value] (to-pg-json value))
IPersistentVector IPersistentVector
(sql-value [value] (to-pg-json value))) (sql-value [value] (to-pg-json value)))
(defmacro with-trx [& body]
"Performs a set of queries in transaction."
`(conman/with-transaction [*db*]
~@body))
(defn update! [& args]
(apply jdbc/update! *db* args))

View File

@ -5,6 +5,7 @@
[compojure.api.meta :refer [restructure-param]] [compojure.api.meta :refer [restructure-param]]
[buddy.auth.accessrules :refer [restrict]] [buddy.auth.accessrules :refer [restrict]]
[buddy.auth :refer [authenticated?]] [buddy.auth :refer [authenticated?]]
[commiteth.db.core :as db]
[commiteth.db.users :as users] [commiteth.db.users :as users]
[commiteth.db.usage-metrics :as usage-metrics] [commiteth.db.usage-metrics :as usage-metrics]
[commiteth.db.repositories :as repositories] [commiteth.db.repositories :as repositories]
@ -234,6 +235,15 @@
(if (= 1 result) (if (= 1 result)
(ok) (ok)
(internal-server-error))))) (internal-server-error)))))
(POST "/hidden" []
:auth-rules authenticated?
:body-params [user-id :- Long, hidden :- Boolean]
:summary "(Un)mark a user as being hidden (not visible in rating tables)."
(db/with-trx
(db/update! :users {:is_hidden hidden} ["id = ?" user-id]))
(ok))
(GET "/repositories" {:keys [params]} (GET "/repositories" {:keys [params]}
:auth-rules authenticated? :auth-rules authenticated?
:current-user user :current-user user