Improve account search
This commit is contained in:
parent
f6f905656d
commit
e77a2a9ed3
1 changed files with 15 additions and 4 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
(filter (fn [post]
|
(filter (fn [post]
|
||||||
(or (match? (j/get post :content))
|
(or (match? (j/get post :content))
|
||||||
(match? (j/get-in post [:account :acct])) ; search for url + username of poster
|
(match? (j/get-in post [:account :acct])) ; search for url + username of poster
|
||||||
|
(match? (j/get-in post [:account :display_name])) ; search for display-name of poster
|
||||||
(some #(match? (j/get % :username)) (j/get post :mentions))
|
(some #(match? (j/get % :username)) (j/get post :mentions))
|
||||||
(some #(some-> (j/get % :description) match?) (j/get post :media_attachments))))))) ; search in alt text
|
(some #(some-> (j/get % :description) match?) (j/get post :media_attachments))))))) ; search in alt text
|
||||||
|
|
||||||
|
|
@ -30,12 +31,22 @@
|
||||||
(some #(some-> (j/get % :description) match?) (j/get post :media_attachments))))))) ; search in descriptions of attachments
|
(some #(some-> (j/get % :description) match?) (j/get post :media_attachments))))))) ; search in descriptions of attachments
|
||||||
|
|
||||||
(defn from-matcher [term]
|
(defn from-matcher [term]
|
||||||
(filter (fn [post]
|
; the account of the person that created the account is usually displayed
|
||||||
(str/starts-with? (j/get-in post [:account :acct]) term))))
|
; slightly different compared to mentioned accounts. especially you'll see the
|
||||||
|
; persons chosen display name only for the OP, and this matcher taks this into
|
||||||
|
; account by allowing you to search for both handle and display name.
|
||||||
|
(let [term (str/replace term #"^@" "")
|
||||||
|
begin-match? (partial re-find (->regex (str "^" term)))
|
||||||
|
fuzzy-match? (partial re-find (->regex term))]
|
||||||
|
(filter (fn [post]
|
||||||
|
(or (begin-match? (j/get-in post [:account :acct]))
|
||||||
|
(fuzzy-match? (j/get-in post [:account :display_name])))))))
|
||||||
|
|
||||||
(defn mention-matcher [term]
|
(defn mention-matcher [term]
|
||||||
(filter (fn [post]
|
(let [term (str/replace term #"^@" "")
|
||||||
(some #(str/starts-with? (j/get % :username) term) (j/get post :mentions)))))
|
begin-match? (partial re-find (->regex (str "^" term)))]
|
||||||
|
(filter (fn [post]
|
||||||
|
(some #(begin-match? (j/get % :acct)) (j/get post :mentions))))))
|
||||||
|
|
||||||
(defn date-before-matcher [term]
|
(defn date-before-matcher [term]
|
||||||
(filter #(< (j/get % :created_at) term)))
|
(filter #(< (j/get % :created_at) term)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue