aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-search.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-10-13 11:13:04 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-10-13 11:23:45 +0200
commitab62022b50ba5d005d6da5d4bdec4f83ce673bc7 (patch)
treebb73756f0f9389f638a4b949f9a63447750d3911 /lisp/mastodon-search.el
parent31908e88a2dd8a874805952cba7d0805af3d9f80 (diff)
implement following "accounts" search. FIX #493.
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r--lisp/mastodon-search.el30
1 files changed, 21 insertions, 9 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 40cf15a..436041d 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -149,21 +149,28 @@ PRINT-FUN is the function used to print the data from the response."
&optional type following account-id)
"Prompt for a search QUERY and return accounts, statuses, and hashtags.
TYPE is a member of `mastodon-search-types'.
-FOLLOWING means limit search to accounts followed.
-ACCOUNT-ID means limit search to that account."
+FOLLOWING means limit to accounts followed, for \"accounts\" type only.
+A single prefix arg also sets FOLLOWING to true.
+ACCOUNT-ID means limit search to that account, for \"statuses\" type only."
;; TODO: handle account search, buffer name etc.
;; TODO: handle no results
(interactive "sSearch mastodon for: ")
(let* ((url (format "%s/api/v2/search" mastodon-instance-url))
+ (following (when (or following
+ (equal current-prefix-arg '(4)))
+ "true"))
(type (or type
- (completing-read "Search type: "
- mastodon-search-types
- nil t)))
+ (if (equal current-prefix-arg '(4))
+ "accounts" ; if FOLLOWING, must be "accounts"
+ (completing-read "Search type: "
+ mastodon-search-types
+ nil t))))
(buffer (format "*mastodon-search-%s-%s*" type query))
- (params `(("q" . ,query)
- ,(when type `("type" . ,type))
- ,(when following `("following" . ,following))
- ,(when account-id `("account_id" . ,account-id))))
+ (params (cl-remove nil
+ `(("q" . ,query)
+ ,(when type `("type" . ,type))
+ ,(when following `("following" . ,following))
+ ,(when account-id `("account_id" . ,account-id)))))
(response (mastodon-http--get-json url params))
(accts (when (equal type "accounts")
(alist-get 'accounts response)))
@@ -215,6 +222,11 @@ ACCOUNT-ID means limit search to that account."
((equal type "statuses")
(mastodon-search--search-query query "hashtags")))))
+(defun mastodon-serach--query-accounts-followed (query)
+ "Run an accounts search QUERY, limited to your followers."
+ (interactive "sSearch mastodon for: ")
+ (mastodon-search--search-query query "accounts" :following))
+
(defun mastodon-search--insert-users-propertized (json &optional note)
"Insert users list into the buffer.
JSON is the data from the server. If NOTE is non-nil, include