 ; TODO: some way to search for a tag with spaces in it?
 (def query-parser
   (insta/parser
-    "S ::= ( TAG / DOT ) *
-    DOT ::= #'(?s).'
+    "S   ::= ( TAG / USER / DOT ) *
+    DOT  ::= #'(?s).'
     <ws> ::= #'\\s*'
-    TAG ::= <'#'> #'[^ ]+'
+    TAG  ::= <'#'> #'[^ ]+'
+    USER ::= <'@'> #'[^ ]+'
     "))
 
 (defn squash

  text 'foo'"
  [user-id [query group-id]]
  ; TODO: pagination?
  (let [{:keys [text tags]} (parse-query query)
        search-db (db/db)
        tag-search (when (seq tags)
                     (set (d/q '[:find ?t-id (max ?time)

                                    [(fulltext $ :message/content ?txt) [[?m]]]]
                                  search-db
                                  text
                                  group-id))))
        results [text-search tag-search user-search]]
    (->> (remove nil? results)
         (apply intersection)
         (filter (comp (partial thread/user-can-see-thread? user-id) first))
         ; sorting the ids so we can have a consistent order of results
         (sort-by second #(compare %2 %1))
