           channel-id (Integer/parseInt (:channel-id params))
           thread-id (Integer/parseInt (:thread-id params))]
       (get-messages channel-id thread-id))))
-
-(defn add-msg [channel-id thread-id msg]
-  (korma/insert messages
-    (korma/values {:channel_id channel-id
-                   :thread_id thread-id
-                   :message msg})))
 
 (defn chat-thread-ws-handler [ch request]
   (let [params (:route-params request)

          lat (Double/parseDouble (:lat params))]
      (get-channels lon lat))))

(defn new-channel [channel-name lon lat]
  (korma/insert channels
    (korma/values
      {:name channel-name
       :location (korma/raw (geoFromText lon lat))})))

(defn new-channel-handler [request]
  (edn-response
    (let [body (read-string (slurp (:body request)))
          geolocation (:geolocation body)]
      (new-channel (:channel-name body) (:lon geolocation) (:lat geolocation)))))

(defn get-threads [channel-id]
  (korma/select threads
    (korma/where {:channel_id channel-id})))

(defn chat-threads-handler [request]
  (edn-response

          channel-id (Integer/parseInt (:channel-id params))]
      (get-threads channel-id))))

(defn new-chat-thread-handler [request]
  (edn-response
    (let [params (:route-params request)
          channel-id (Integer/parseInt (:channel-id params))
          body (read-string (slurp (:body request)))]
      (add-chat-thread channel-id (:thread-descr body)))))

(defn chat-messages-handler [request]
  (edn-response
