mirror of
https://github.com/unclebob/more-speech.git
synced 2024-09-30 10:30:56 +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
@ -77,5 +77,13 @@
|
|||||||
{:id 153N :pubkey 2N :content ""
|
{:id 153N :pubkey 2N :content ""
|
||||||
:tags [[:e (util/hexify 1N)]
|
:tags [[:e (util/hexify 1N)]
|
||||||
[:p (util/hexify 88N)]]})))
|
[: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]
|
(defn match-string-target [target event]
|
||||||
(let [content (formatters/replace-references event)
|
(let [content (formatters/replace-references event)
|
||||||
author-name (:name (gateway/get-profile (get-db) (:pubkey 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))
|
petname (contact-list/get-petname (:pubkey event))
|
||||||
subject (get-subject event)
|
subject (get-subject event)
|
||||||
re-target (re-pattern target)]
|
re-target (re-pattern target)]
|
||||||
(or (re-find re-target content)
|
(or (re-find re-target content)
|
||||||
(and subject (re-find re-target subject))
|
(and subject (re-find re-target subject))
|
||||||
(and author-name (re-find re-target author-name))
|
(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]
|
(defn match-npub [target event]
|
||||||
(match-id (bech32/address->number target) event))
|
(match-id (bech32/address->number target) event))
|
||||||
|
Loading…
Reference in New Issue
Block a user