emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon e0b2f1a5eb 18/47: mastodon-http--api-search fun (


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon e0b2f1a5eb 18/47: mastodon-http--api-search fun (search uses api v2)
Date: Fri, 13 Oct 2023 19:00:56 -0400 (EDT)

branch: elpa/mastodon
commit e0b2f1a5eb1dab3b99f974b030bdbb866bd48dae
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    mastodon-http--api-search fun (search uses api v2)
---
 lisp/mastodon-http.el   | 4 ++++
 lisp/mastodon-search.el | 9 +++------
 lisp/mastodon-tl.el     | 4 +++-
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 8741972519..33f6012119 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -53,6 +53,10 @@
   (concat mastodon-instance-url "/api/"
           mastodon-http--api-version "/" endpoint))
 
+(defun mastodon-http--api-search ()
+  "Return Mastodon API url for the /search endpoind (v2)."
+  (format "%s/api/v2/search" mastodon-instance-url))
+
 (defun mastodon-http--response ()
   "Capture response buffer content as string."
   (with-current-buffer (current-buffer)
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 436041defb..602df8d43b 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -76,7 +76,7 @@ Returns a nested list containing user handle, display name, 
and URL."
 (defun mastodon-search--search-tags-query (query)
   "Return an alist containing tag strings plus their URLs.
 QUERY is the string to search."
-  (let* ((url (format "%s/api/v2/search" mastodon-instance-url))
+  (let* ((url (mastodon-http--api-search))
          (params `(("q" . ,query) ("type" . "hashtags")))
          (response (mastodon-http--get-json url params :silent))
          (tags (alist-get 'hashtags response)))
@@ -152,10 +152,9 @@ TYPE is a member of `mastodon-search-types'.
 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))
+  (let* ((url (mastodon-http--api-search))
          (following (when (or following
                               (equal current-prefix-arg '(4)))
                       "true"))
@@ -180,8 +179,6 @@ ACCOUNT-ID means limit search to that account, for 
\"statuses\" type only."
                      (alist-get 'statuses response)))
          (tags-list (when tags
                       (mapcar #'mastodon-search--get-hashtag-info tags))))
-    ;; (toots-list-json (when statuses ; v slow, but do we have a choice?
-    ;;                    (mastodon-search--get-full-statuses-data statuses))))
     (with-mastodon-buffer buffer #'mastodon-mode nil
       (mastodon-search-mode)
       (mastodon-tl--set-buffer-spec buffer "api/v2/search" nil
@@ -197,7 +194,7 @@ ACCOUNT-ID means limit search to that account, for 
\"statuses\" type only."
       ;; status results:
       (when statuses
         (mastodon-search--format-heading "STATUSES")
-        (mapc #'mastodon-tl--toot statuses)) ;toots-list-json))
+        (mapc #'mastodon-tl--toot statuses))
       (goto-char (point-min))
       (message
        (substitute-command-keys
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 25ffcd70c5..d32b80680d 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2249,7 +2249,9 @@ PARAMS is used to send any parameters needed to correctly 
update
 the current view."
   (let* ((args `(("max_id" . ,(mastodon-tl--as-string id))))
          (args (if params (push (car args) params) args))
-         (url (mastodon-http--api endpoint)))
+         (url (if (string-suffix-p "search" endpoint)
+                  (mastodon-http--api-search)
+                (mastodon-http--api endpoint))))
     (apply #'mastodon-http--get-json-async url args callback cbargs)))
 
 (defun mastodon-tl--updated-json (endpoint id &optional params)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]