processMsg conn client (PostMessage msg) = do
  client' <- refreshClient conn client
  let r = clientRoomId client'
  case r of 
    Just rid -> do -- client in a room 
      r <- findRoom conn rid
      let q = "insert into messages (room_id, client_id, client_nick, content) values (?, ?, ?, ?) returning message_id, created"
      ((mid,time):_) :: [(Int, UTCTime)] <- query conn q (rid, clientId client', nickName client', msg)
      return [Broadcast (latLng r) (tupClient client') rid msg]
    Nothing -> do
      return []

-- catchall
processMsg conn client (PostMessage msg) = do
  client' <- refreshClient conn client
  let r = clientRoomId client'
  case r of 
    Just rid -> do -- client in a room 
      r <- findRoom conn rid
      let q = "insert into messages (room_id, client_id, client_nick, content) values (?, ?, ?, ?) returning message_id, created"
      ((mid,time):_) :: [(Int, UTCTime)] <- query conn q (rid, clientId client', nickName client', msg)
      return [Broadcast (latLng r) (tupClient client') rid msg]
    Nothing -> do
      return []

-- catchall
processMsg conn client (PostMessage msg) = do
  client' <- refreshClient conn client
  let r = clientRoomId client'
  case r of 
    Just rid -> do -- client in a room 
      r <- findRoom conn rid
      let q = "insert into messages (room_id, client_id, client_nick, content) values (?, ?, ?, ?) returning message_id, created"
      ((mid,time):_) :: [(Int, UTCTime)] <- query conn q (rid, clientId client', nickName client', msg)
      return [Broadcast (latLng r) (tupClient client') rid msg]
    Nothing -> do
      return []

-- catchall