     (if (db/with-conn (db/user-in-group? user-id (?data :group-id)))
       (let [data (assoc ?data :inviter-id user-id)
             invitation (db/with-conn (db/create-invitation! data))]
-        (if-let [invited-user (db/with-conn (db/user-with-email (invitation :invitee-email)))]
+        (if-let [invited-user (db/with-conn
+                                (db/user-with-email (invitation :invitee-email)))]
           (chsk-send! (invited-user :id) [:chat/invitation-received invitation])
           (invites/send-invite invitation)))
       ; TODO: indicate permissions error to user?
-      (timbre/warnf "User %s attempted to invite %s to a group %s they don't have access to"
-                    user-id (?data :invitee-email) (?data :group-id)))))
+      (timbre/warnf
+        "User %s attempted to invite %s to a group %s they don't have access to"
+        user-id (?data :invitee-email) (?data :group-id)))))
 
 (defmethod event-msg-handler :chat/invitation-accept
   [{:as ev-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]

                               (db/with-conn (db/get-users-in-group group-id))))]
    (doseq [uid ids-to-send-to]
      (chsk-send! uid info))))

(defmethod event-msg-handler :chsk/uidport-open
  [{:as ev-msg :keys [event id ring-req]}]
  (when-let [user-id (get-in ring-req [:session :user-id])]
    (broadcast-user-change user-id [:user/connected user-id])))

(defmethod event-msg-handler :chsk/uidport-close
  [{:as ev-msg :keys [event id ring-req]}]
  (when-let [user-id (get-in ring-req [:session :user-id])]
    (broadcast-user-change user-id [:user/disconnected user-id])))

(defn user-can-message? [user-id ?data]
  (db/with-conn

          (when (notify-rules/notify? uid rules new-message)
            (if (online? uid)
              (chsk-send! uid [:chat/notify-message new-message])
              (-> (email/create-message
                    [(db/get-thread (new-message :thread-id))])
                  (assoc :subject "Notification from Braid")
                  (->> (email/send-message (db/user-email uid)))))))))))

;; Handlers

(defmethod event-msg-handler :chsk/ws-ping
  [ev-msg]
  ; Do nothing, just avoid unhandled event message
  )

(defmethod event-msg-handler :chsk/uidport-open
  [{:as ev-msg :keys [event id ring-req]}]
  (when-let [user-id (get-in ring-req [:session :user-id])]
    (broadcast-user-change user-id [:user/connected user-id])))

(defmethod event-msg-handler :chsk/uidport-close
  [{:as ev-msg :keys [event id ring-req]}]
  (when-let [user-id (get-in ring-req [:session :user-id])]
    (broadcast-user-change user-id [:user/disconnected user-id])))

(defmethod event-msg-handler :chat/new-message
  [{:as ev-msg :keys [event id ?data ring-req ?reply-fn send-fn]}]
