diff --git a/spec/more_speech/nostr/tab_searcher_spec.clj b/spec/more_speech/nostr/tab_searcher_spec.clj index 93cfdf9..5f6cf1c 100644 --- a/spec/more_speech/nostr/tab_searcher_spec.clj +++ b/spec/more_speech/nostr/tab_searcher_spec.clj @@ -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)]]}))) ) ) diff --git a/src/more_speech/nostr/tab_searcher.clj b/src/more_speech/nostr/tab_searcher.clj index be813d9..34b39f0 100644 --- a/src/more_speech/nostr/tab_searcher.clj +++ b/src/more_speech/nostr/tab_searcher.clj @@ -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))