 
 (defn http-delete-form-by-key
   "Deletes all forms matching the form-key"
-  [request]
+  [mqtt request]
   (let [form-key (URLDecoder/decode (get-in request [:path-params :form-key]))
         forms    (formmodel/find-by-form-key form-key)]
     (doall (map delete-form-by-id forms))
+    (mqttapi/publish-scmessage mqtt "/config/update" (scm/map->SCMessage {:action (.value SCCommand/CONFIG_REMOVE_FORM)}))
     (response/ok (str "Deleted form " form-key))))
 
 (defn http-submit-form-data

        device-identifier (:client (:metadata form-data))]
    (formmodel/add-form-data form-data form-id device-identifier)))

(defn- routes []
  #{["/api/forms"                :get    (conj common-interceptors `http-get-all-forms)]
    ["/api/forms"                :post   (conj common-interceptors check-auth `http-create-form)]
    ["/api/forms/:form-key"      :delete (conj common-interceptors check-auth `http-delete-form-by-key)]
    ["/api/forms/:form-key"      :get    (conj common-interceptors check-auth `http-get-form-by-form-key)]
    ;; todo: need to figure out why forms causes a route conflict
    ["/api/form/:form-id/submit"   :post   (conj common-interceptors check-auth `http-submit-form-data) :constraints {:form-id #"[0-9]+"}]

            [spacon.models.form :as formmodel]
            [spacon.components.mqtt :as mqttapi]
            [clojure.spec :as s]
            [spacon.components.mqtt :as mqttapi]
            [clojure.data.json :as json]
            [spacon.entity.scmessage :as scm])
  (:import java.net.URLDecoder
           (com.boundlessgeo.spatialconnect.schema SCCommand)))

(defn http-get-all-forms
  ;; todo: get all the forms for all the teams that the calling user belongs to
