aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-http.el34
-rw-r--r--lisp/mastodon-search.el12
-rw-r--r--lisp/mastodon.el5
3 files changed, 10 insertions, 41 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index c94ea7a..c1ab3fb 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -256,40 +256,6 @@ PARAMS should be an alist as required by `url-build-query-string'."
(let ((query-string (url-build-query-string params)))
(concat url "?" query-string)))
-;; search functions:
-(defun mastodon-http--process-json-search ()
- "Process JSON returned by a search query to the server."
- (goto-char (point-min))
- (re-search-forward "^$" nil 'move)
- (let ((json-string
- (decode-coding-string
- (buffer-substring-no-properties (point) (point-max))
- 'utf-8)))
- (kill-buffer)
- (json-read-from-string json-string)))
-
-(defun mastodon-http--get-search-json (url query &optional params silent)
- "Make GET request to URL, searching for QUERY and return JSON response.
-PARAMS is an alist of any extra parameters to send with the request.
-SILENT means don't message."
- (let ((buffer (mastodon-http--get-search url query params silent)))
- (with-current-buffer buffer
- (mastodon-http--process-json-search))))
-
-(defun mastodon-http--get-search (base-url query &optional params silent)
- "Make GET request to BASE-URL, searching for QUERY.
-Pass response buffer to CALLBACK function.
-PARAMS is an alist of any extra parameters to send with the request.
-SILENT means don't message."
- (mastodon-http--authorized-request
- "GET"
- (let* ((query-str (mastodon-http--build-query-string
- `(("q" . ,(url-hexify-string query)))))
- (params-str (mastodon-http--build-query-string params))
- (url (concat base-url "?" query-str (when params-str
- (concat "&" params-str)))))
- (mastodon-http--url-retrieve-synchronously url silent))))
-
;; profile update functions
(defun mastodon-http--patch-json (url &optional params)
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index fee79c4..f83cccb 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -61,8 +61,8 @@ Returns a nested list containing user handle, display name, and URL."
(interactive "sSearch mastodon for: ")
(let* ((url (mastodon-http--api "accounts/search"))
(response (if (equal mastodon-toot--completion-style-for-mentions "following")
- (mastodon-http--get-search-json url query '(("following" . "true")))
- (mastodon-http--get-search-json url query))))
+ (mastodon-http--get-json url `(("q" . ,query) ("following" . "true")))
+ (mastodon-http--get-json url `(("q" . ,query))))))
(mapcar #'mastodon-search--get-user-info-@ response)))
;; functions for tags completion:
@@ -72,8 +72,10 @@ Returns a nested list containing user handle, display name, and URL."
QUERY is the string to search."
(interactive "sSearch for hashtag: ")
(let* ((url (format "%s/api/v2/search" mastodon-instance-url))
- (type-param '(("type" . "hashtags")))
- (response (mastodon-http--get-search-json url query type-param))
+ ;; (type-param '(("type" . "hashtags")))
+ (params `(("q" . ,query)
+ ("type" . "hashtags")))
+ (response (mastodon-http--get-json url params))
(tags (alist-get 'hashtags response)))
(mapcar #'mastodon-search--get-hashtag-info tags)))
@@ -112,7 +114,7 @@ QUERY is the string to search."
(interactive "sSearch mastodon for: ")
(let* ((url (format "%s/api/v2/search" mastodon-instance-url))
(buffer (format "*mastodon-search-%s*" query))
- (response (mastodon-http--get-search-json url query))
+ (response (mastodon-http--get-json url `(("q" . ,query))))
(accts (alist-get 'accounts response))
(tags (alist-get 'hashtags response))
(statuses (alist-get 'statuses response))
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index cfe6681..4097b27 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -291,8 +291,9 @@ not, just browse the URL in the normal fashion."
(browse-url query)
(message "Performing lookup...")
(let* ((url (format "%s/api/v2/search" mastodon-instance-url))
- (param '(("resolve" . "t"))) ; webfinger
- (response (mastodon-http--get-search-json url query param :silent)))
+ (params `(("q" . ,query)
+ ("resolve" . "t"))) ; webfinger
+ (response (mastodon-http--get-json url params :silent)))
(cond ((not (seq-empty-p
(alist-get 'statuses response)))
(let* ((statuses (assoc 'statuses response))