mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 02:21:02 +00:00
Search is working. More could be added I suppose. Added treating petnames as ids.
This commit is contained in:
parent
aee5ca8af3
commit
280ed9b187
@ -29,14 +29,14 @@
|
||||
(it "should match if re-target is in content"
|
||||
(should
|
||||
(match-target "#\"t\\w+t\"" {:id 1N :pubkey 2N
|
||||
:tags []
|
||||
:content "the target is here"})))
|
||||
:tags []
|
||||
:content "the target is here"})))
|
||||
|
||||
(it "should match if re-target is in subject"
|
||||
(should
|
||||
(match-target "#\"t\\w+t\"" {:id 1N :pubkey 2N
|
||||
:tags [[:e 1N] [:subject "the target is here"]]
|
||||
:content "nope"})))
|
||||
:tags [[:e 1N] [:subject "the target is here"]]
|
||||
:content "nope"})))
|
||||
|
||||
(it "should match if user name is target and user is embedded with #[n]"
|
||||
(gateway/add-profile @db 1N {:name "user-name"})
|
||||
@ -77,5 +77,13 @@
|
||||
{:id 153N :pubkey 2N :content ""
|
||||
:tags [[:e (util/hexify 1N)]
|
||||
[:p (util/hexify 88N)]]})))
|
||||
|
||||
(it "should match if petname matches any p tag"
|
||||
(set-mem :pubkey 99N)
|
||||
(gateway/add-contacts @db 99N [{:pubkey 1N :petname "pet"}])
|
||||
(should (match-target "pet"
|
||||
{:id 153N :pubkey 2N :content ""
|
||||
:tags [[:e (util/hexify 1N)]
|
||||
[:p (util/hexify 88N)]]})))
|
||||
)
|
||||
)
|
||||
|
@ -29,13 +29,15 @@
|
||||
(defn match-string-target [target event]
|
||||
(let [content (formatters/replace-references event)
|
||||
author-name (:name (gateway/get-profile (get-db) (:pubkey event)))
|
||||
author-id (contact-list/get-pubkey-from-petname target)
|
||||
petname (contact-list/get-petname (:pubkey event))
|
||||
subject (get-subject event)
|
||||
re-target (re-pattern target)]
|
||||
(or (re-find re-target content)
|
||||
(and subject (re-find re-target subject))
|
||||
(and author-name (re-find re-target author-name))
|
||||
(and petname (re-find re-target petname)))))
|
||||
(and petname (re-find re-target petname))
|
||||
(and author-id (match-id author-id event)))))
|
||||
|
||||
(defn match-npub [target event]
|
||||
(match-id (bech32/address->number target) event))
|
||||
|
Loading…
Reference in New Issue
Block a user