Search is working. More could be added I suppose. Added treating petnames and usernames as ids.

This commit is contained in:
Robert C. Martin 2023-02-21 14:24:07 -06:00
parent 280ed9b187
commit 2286aab967
2 changed files with 9 additions and 0 deletions

View File

@ -85,5 +85,13 @@
{:id 153N :pubkey 2N :content ""
:tags [[:e (util/hexify 1N)]
[:p (util/hexify 88N)]]})))
(it "should match if username matches any p tag"
(set-mem :pubkey 99N)
(gateway/add-profile @db 1N {:name "username"})
(should (match-target "username"
{:id 153N :pubkey 2N :content ""
:tags [[:e (util/hexify 1N)]
[:p (util/hexify 88N)]]})))
)
)

View File

@ -30,6 +30,7 @@
(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)
author-id (or author-id (gateway/get-id-from-username (get-db) target))
petname (contact-list/get-petname (:pubkey event))
subject (get-subject event)
re-target (re-pattern target)]