             (assoc bad-resp :body "No such group or the group is private")
             (if-let [user-id (get-in req [:session :user-id])]
               (do
-                (when-not (db/user-in-group? user-id group-id)
-                  (do
-                    (db/user-add-to-group! user-id group-id)
-                    (db/user-subscribe-to-group-tags! user-id group-id)
-                    (sync/broadcast-group-change
-                      group-id
-                      [:group/new-user (db/user-by-id user-id)])))
+                (join-group user-id group-id)
                 (let [referer (get-in req [:headers "referer"] (env :site-url))
                       [proto _ referrer-domain] (string/split referer #"/")]
                   {:status 302

  ; TODO: add mobile routse for public joining & password resets
  (GET "/*" []
    (get-html "mobile")))

(defroutes api-public-routes
  ; check if already logged in

              (assoc bad-resp :body "Invalid email")
              (if (db/user-with-email email)
                (assoc bad-resp
                       :body (str "A user is already registered with that email.\n"
                                  "Log in and try joining"))
                (let [user-id (register-user email group-id)
                      referer (get-in req [:headers "referer"] (env :site-url))
                      [proto _ referrer-domain] (string/split referer #"/")]
                  {:status 302 :headers {"Location" (str proto "//" referrer-domain)}
                   :session (assoc (req :session) :user-id id)
                   :body ""}))))))))
