aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-24 15:59:42 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-24 15:59:42 +0100
commit99c1c63c020de258e48f6636b563421187fb6dac (patch)
treea5b2eaf2a078ced0898658f8406d2ce356101f72 /lisp
parent69c817d1a901f0aaa871f2679659f64fc438c40b (diff)
parent54bf253a26c899a21dec819033b51831684a6eb5 (diff)
Merge branch 'params-always-in-http-el' into develop
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-http.el123
-rw-r--r--lisp/mastodon-profile.el28
-rw-r--r--lisp/mastodon-search.el12
-rw-r--r--lisp/mastodon-tl.el105
-rw-r--r--lisp/mastodon-toot.el9
-rw-r--r--lisp/mastodon.el5
6 files changed, 128 insertions, 154 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 37770ef..69a571d 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -114,19 +114,19 @@ Unless UNAUTHENTICATED-P is non-nil."
(concat "Bearer " (mastodon-auth--access-token)))))))
,body))
-(defun mastodon-http--build-query-string (args)
- "Build a request query string from ARGS."
+(defun mastodon-http--build-params-string (params)
+ "Build a request parameters string from parameters alist PARAMS."
;; (url-build-query-string args nil))
;; url-build-query-string adds 'nil' to empty params so lets stay with our
;; own:
- (mapconcat (lambda (arg)
- (concat (url-hexify-string (car arg))
+ (mapconcat (lambda (p)
+ (concat (url-hexify-string (car p))
"="
- (url-hexify-string (cdr arg))))
- args
+ (url-hexify-string (cdr p))))
+ params
"&"))
-(defun mastodon-http--build-array-args-alist (param-str array)
+(defun mastodon-http--build-array-params-alist (param-str array)
"Return parameters alist using PARAM-STR and ARRAY param values.
Used for API form data parameters that take an array."
(cl-loop for x in array
@@ -140,7 +140,7 @@ Authorization header is included by default unless UNAUTHENTICATED-P is non-nil.
"POST"
(let ((url-request-data
(when args
- (mastodon-http--build-query-string args)))
+ (mastodon-http--build-params-string args)))
(url-request-extra-headers
(append url-request-extra-headers ; auth set in macro
;; pleroma compat:
@@ -151,27 +151,34 @@ Authorization header is included by default unless UNAUTHENTICATED-P is non-nil.
(mastodon-http--url-retrieve-synchronously url)))
unauthenticated-p))
-(defun mastodon-http--get (url &optional silent)
+(defun mastodon-http--get (url &optional params silent)
"Make synchronous GET request to URL.
-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"
- (mastodon-http--url-retrieve-synchronously url silent)))
+ ;; url-request-data doesn't seem to work with GET requests:
+ (let ((url (if params
+ (concat url "?"
+ (mastodon-http--build-params-string params))
+ url)))
+ (mastodon-http--url-retrieve-synchronously url silent))))
-(defun mastodon-http--get-response (url &optional no-headers silent vector)
+(defun mastodon-http--get-response (url &optional params no-headers silent vector)
"Make synchronous GET request to URL. Return JSON and response headers.
+PARAMS is an alist of any extra parameters to send with the request.
SILENT means don't message.
NO-HEADERS means don't collect http response headers.
VECTOR means return json arrays as vectors."
- (with-current-buffer (mastodon-http--get url silent)
+ (with-current-buffer (mastodon-http--get url params silent)
(mastodon-http--process-response no-headers vector)))
-(defun mastodon-http--get-json (url &optional silent vector)
+(defun mastodon-http--get-json (url &optional params silent vector)
"Return only JSON data from URL request.
+PARAMS is an alist of any extra parameters to send with the request.
SILENT means don't message.
VECTOR means return json arrays as vectors."
- (car (mastodon-http--get-response url :no-headers silent vector)))
+ (car (mastodon-http--get-response url params :no-headers silent vector)))
(defun mastodon-http--process-json ()
"Return only JSON data from async URL request.
@@ -214,71 +221,41 @@ Callback to `mastodon-http--get-response-async', usually
(cons (car list) (cadr list))))
head-list)))
-(defun mastodon-http--delete (url &optional args)
- "Make DELETE request to URL."
- (let ((url-request-data
- (when args
- (mastodon-http--build-query-string args))))
+(defun mastodon-http--delete (url &optional params)
+ "Make DELETE request to URL.
+PARAMS is an alist of any extra parameters to send with the request."
+ ;; url-request-data only works with POST requests?
+ (let ((url
+ (if params
+ (concat url "?"
+ (mastodon-http--build-params-string params))
+ url)))
(mastodon-http--authorized-request
"DELETE"
(with-temp-buffer
(mastodon-http--url-retrieve-synchronously url)))))
-(defun mastodon-http--put (url &optional args headers)
- "Make PUT request to URL."
+(defun mastodon-http--put (url &optional params headers)
+ "Make PUT request to URL.
+PARAMS is an alist of any extra parameters to send with the request."
(mastodon-http--authorized-request
"PUT"
(let ((url-request-data
- (when args
- (mastodon-http--build-query-string args)))
+ (when args (mastodon-http--build-params-string params)))
(url-request-extra-headers
(append url-request-extra-headers ; auth set in macro
;; pleroma compat:
(unless (assoc "Content-Type" headers)
'(("Content-Type" . "application/x-www-form-urlencoded")))
headers)))
- (with-temp-buffer
- (mastodon-http--url-retrieve-synchronously url)))))
+ (with-temp-buffer (mastodon-http--url-retrieve-synchronously url)))))
(defun mastodon-http--append-query-string (url params)
"Append PARAMS to URL as query strings and return it.
-
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 param silent)
- "Make GET request to URL, searching for QUERY and return JSON response.
-PARAM is any extra parameters to send with the request.
-SILENT means don't message."
- (let ((buffer (mastodon-http--get-search url query param silent)))
- (with-current-buffer buffer
- (mastodon-http--process-json-search))))
-
-(defun mastodon-http--get-search (base-url query &optional param silent)
- "Make GET request to BASE-URL, searching for QUERY.
-Pass response buffer to CALLBACK function.
-PARAM is a formatted request parameter, eg 'following=true'.
-SILENT means don't message."
- (mastodon-http--authorized-request
- "GET"
- (let ((url (if param
- (concat base-url "?" param "&q=" (url-hexify-string query))
- (concat base-url "?q=" (url-hexify-string query)))))
- (mastodon-http--url-retrieve-synchronously url silent))))
-
;; profile update functions
(defun mastodon-http--patch-json (url &optional params)
@@ -294,30 +271,38 @@ Optionally specify the PARAMS to send."
"PATCH"
(let ((url
(concat base-url "?"
- (mastodon-http--build-query-string params))))
+ (mastodon-http--build-params-string params))))
(mastodon-http--url-retrieve-synchronously url))))
;; Asynchronous functions
-(defun mastodon-http--get-async (url &optional callback &rest cbargs)
+(defun mastodon-http--get-async (url &optional params callback &rest cbargs)
"Make GET request to URL.
-Pass response buffer to CALLBACK function with args CBARGS."
- (mastodon-http--authorized-request
- "GET"
- (url-retrieve url callback cbargs)))
+Pass response buffer to CALLBACK function with args CBARGS.
+PARAMS is an alist of any extra parameters to send with the request."
+ (let ((url (if params
+ (concat url "?"
+ (mastodon-http--build-params-string params))
+ url)))
+ (mastodon-http--authorized-request
+ "GET"
+ (url-retrieve url callback cbargs))))
-(defun mastodon-http--get-response-async (url callback &rest args)
+(defun mastodon-http--get-response-async (url &optional params callback &rest args)
"Make GET request to URL. Call CALLBACK with http response and ARGS."
(mastodon-http--get-async
url
+ params
(lambda (status)
(when status ;; only when we actually get sth?
(apply callback (mastodon-http--process-response) args)))))
-(defun mastodon-http--get-json-async (url callback &rest args)
- "Make GET request to URL. Call CALLBACK with json-list and ARGS."
+(defun mastodon-http--get-json-async (url &optional params callback &rest args)
+ "Make GET request to URL. Call CALLBACK with json-list and ARGS.
+PARAMS is an alist of any extra parameters to send with the request."
(mastodon-http--get-async
url
+ params
(lambda (status)
(when status ;; only when we actually get sth?
(apply callback (mastodon-http--process-json) args)))))
@@ -331,7 +316,7 @@ Authorization header is included by default unless UNAUTHENTICED-P is non-nil."
(let ((request-timeout 5)
(url-request-data
(when args
- (mastodon-http--build-query-string args))))
+ (mastodon-http--build-params-string args))))
(with-temp-buffer
(url-retrieve url callback cbargs)))))
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index c604bcd..69cd65d 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -36,6 +36,7 @@
(require 'seq)
(require 'cl-lib)
(require 'persist)
+(require 'ts)
(autoload 'mastodon-http--api "mastodon-http.el")
(autoload 'mastodon-http--get-json "mastodon-http.el")
@@ -503,11 +504,10 @@ This endpoint only holds a few preferences. For others, see
(defun mastodon-profile--relationships-get (id)
"Fetch info about logged-in user's relationship to user with id ID."
(let* ((their-id id)
- (url (mastodon-http--api (format
- "accounts/relationships?id[]=%s"
- their-id))))
+ (args `(("id[]" . ,their-id)))
+ (url (mastodon-http--api "accounts/relationships")))
;; FIXME: not sure why we need to do this for relationships only!
- (car (mastodon-http--get-json url))))
+ (car (mastodon-http--get-json url args))))
(defun mastodon-profile--fields-get (&optional account fields)
"Fetch the fields vector (aka profile metadata) from profile of ACCOUNT.
@@ -538,8 +538,9 @@ FIELDS means provide a fields vector fetched by other means."
(defun mastodon-profile--get-statuses-pinned (account)
"Fetch the pinned toots for ACCOUNT."
(let* ((id (mastodon-profile--account-field account 'id))
- (url (mastodon-http--api (format "accounts/%s/statuses?pinned=true" id))))
- (mastodon-http--get-json url)))
+ (args `(("pinned" . "true")))
+ (url (mastodon-http--api (format "accounts/%s/statuses" id))))
+ (mastodon-http--get-json url args)))
(defun mastodon-profile--insert-statuses-pinned (pinned-statuses)
"Insert each of the PINNED-STATUSES for a given account."
@@ -549,18 +550,17 @@ FIELDS means provide a fields vector fetched by other means."
(mastodon-tl--toot pinned-status))
pinned-statuses))
-(defun mastodon-profile--make-profile-buffer-for (account endpoint-type update-function &optional no-reblogs)
+(defun mastodon-profile--make-profile-buffer-for (account endpoint-type
+ update-function
+ &optional no-reblogs)
"Display profile of ACCOUNT, using ENDPOINT-TYPE and UPDATE-FUNCTION."
(let* ((id (mastodon-profile--account-field account 'id))
(args (when no-reblogs '(("exclude_reblogs" . "t"))))
- (base-url (mastodon-http--api (format "accounts/%s/%s" id endpoint-type)))
- (url (if no-reblogs
- (concat base-url "?" (mastodon-http--build-query-string args))
- base-url))
+ (url (mastodon-http--api (format "accounts/%s/%s" id endpoint-type)))
(acct (mastodon-profile--account-field account 'acct))
(buffer (concat "*mastodon-" acct "-" endpoint-type "*"))
(note (mastodon-profile--account-field account 'note))
- (json (mastodon-http--get-json url))
+ (json (mastodon-http--get-json url args))
(locked (mastodon-profile--account-field account 'locked))
(followers-count (mastodon-tl--as-string
(mastodon-profile--account-field
@@ -765,12 +765,14 @@ If the handle does not match a search return then retun NIL."
(let* ((handle (if (string= "@" (substring handle 0 1))
(substring handle 1 (length handle))
handle))
+ (args `(("q" . ,handle)))
(matching-account
(seq-remove
(lambda (x)
(not (string= (alist-get 'acct x) handle)))
(mastodon-http--get-json
- (mastodon-http--api (format "accounts/search?q=%s" handle))))))
+ (mastodon-http--api "accounts/search")
+ args))))
(when (equal 1 (length matching-account))
(elt matching-account 0))))
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 31fcae3..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 (concat "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-tl.el b/lisp/mastodon-tl.el
index d829015..46ec8fe 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -74,8 +74,8 @@
(autoload 'mastodon-auth--get-account-id "mastodon-auth")
(autoload 'mastodon-http--put "mastodon-http")
(autoload 'mastodon-http--process-json "mastodon-http")
-(autoload 'mastodon-http--build-array-args-alist "mastodon-http")
-(autoload 'mastodon-http--build-query-string "mastodon-http")
+(autoload 'mastodon-http--build-array-params-alist "mastodon-http")
+(autoload 'mastodon-http--build-params-string "mastodon-http")
(autoload 'mastodon-notifications--filter-types-list "mastodon-notifications")
(autoload 'mastodon-toot--get-toot-edits "mastodon-toot")
@@ -499,7 +499,7 @@ The result is added as an attachments property to author-byline."
(let ((reblog (alist-get 'reblog toot)))
(when reblog
(concat
- "\n "
+ "\n "
(propertize "Boosted" 'face 'mastodon-boosted-face)
" "
(mastodon-tl--byline-author reblog)))))
@@ -671,20 +671,21 @@ this just means displaying toot client."
'shr-url app-url
'help-echo app-url
'keymap mastodon-tl--shr-map-replacement)))))
- (when edited-time
- (concat
- (if (fontp (char-displayable-p #10r128274))
- " ✍ "
- " [edited] ")
- (propertize
- (format-time-string mastodon-toot-timestamp-format
- edited-parsed)
- 'face 'font-lock-comment-face
- 'timestamp edited-parsed
- 'display (if mastodon-tl--enable-relative-timestamps
- (mastodon-tl--relative-time-description edited-parsed)
- edited-parsed))))
- (propertize "\n ------------\n" 'face 'default))
+ (if edited-time
+ (concat
+ (if (fontp (char-displayable-p #10r128274))
+ " ✍ "
+ " [edited] ")
+ (propertize
+ (format-time-string mastodon-toot-timestamp-format
+ edited-parsed)
+ 'face 'font-lock-comment-face
+ 'timestamp edited-parsed
+ 'display (if mastodon-tl--enable-relative-timestamps
+ (mastodon-tl--relative-time-description edited-parsed)
+ edited-parsed)))
+ "")
+ (propertize "\n ------------\n " 'face 'default))
'favourited-p faved
'boosted-p boosted
'bookmarked-p bookmarked
@@ -1317,39 +1318,24 @@ LINK-HEADER is the http Link header if present."
(defun mastodon-tl--more-json (endpoint id)
"Return JSON for timeline ENDPOINT before ID."
- (let* ((url (mastodon-http--api (concat
- endpoint
- (if (string-match-p "?" endpoint)
- "&"
- "?")
- "max_id="
- (mastodon-tl--as-string id)))))
- (mastodon-http--get-json url)))
+ (let* ((args `(("max_id" . ,(mastodon-tl--as-string id))))
+ (url (mastodon-http--api endpoint)))
+ (mastodon-http--get-json url args)))
(defun mastodon-tl--more-json-async (endpoint id callback &rest cbargs)
"Return JSON for timeline ENDPOINT before ID.
Then run CALLBACK with arguments CBARGS."
- (let* ((url (mastodon-http--api (concat
- endpoint
- (if (string-match-p "?" endpoint)
- "&"
- "?")
- "max_id="
- (mastodon-tl--as-string id)))))
- (apply 'mastodon-http--get-json-async url callback cbargs)))
+ (let* ((args `(("max_id" . ,(mastodon-tl--as-string id))))
+ (url (mastodon-http--api endpoint)))
+ (apply 'mastodon-http--get-json-async url args callback cbargs)))
;; TODO
;; Look into the JSON returned here by Local
(defun mastodon-tl--updated-json (endpoint id)
"Return JSON for timeline ENDPOINT since ID."
- (let ((url (mastodon-http--api (concat
- endpoint
- (if (string-match-p "?" endpoint)
- "&"
- "?")
- "since_id="
- (mastodon-tl--as-string id)))))
- (mastodon-http--get-json url)))
+ (let* ((args `(("since_id" . ,(mastodon-tl--as-string id))))
+ (url (mastodon-http--api endpoint)))
+ (mastodon-http--get-json url args)))
(defun mastodon-tl--property (prop &optional backward)
"Get property PROP for toot at point.
@@ -1429,8 +1415,9 @@ ID is that of the toot to view."
;; refetch current toot in case we just faved/boosted:
(mastodon-http--get-json
(mastodon-http--api (concat "statuses/" id))
+ nil
:silent))
- (context (mastodon-http--get-json url :silent))
+ (context (mastodon-http--get-json url nil :silent))
(marker (make-marker)))
(if (equal (caar toot) 'error)
(message "Error: %s" (cdar toot))
@@ -1703,13 +1690,9 @@ If ID is provided, use that list."
(account (completing-read "Account to remove: "
handles nil t))
(account-id (alist-get account handles nil nil 'equal))
- ;; letting --delete handle the params doesn't work
- ;; so we do it here for now:
- (base-url (mastodon-http--api (format "lists/%s/accounts" list-id)))
- (args (mastodon-http--build-array-args-alist "account_ids[]" `(,account-id)))
- (query-str (mastodon-http--build-query-string args))
- (url (concat base-url "?" query-str))
- (response (mastodon-http--delete url)))
+ (url (mastodon-http--api (format "lists/%s/accounts" list-id)))
+ (args (mastodon-http--build-array-params-alist "account_ids[]" `(,account-id)))
+ (response (mastodon-http--delete url args)))
(mastodon-tl--list-action-triage
response
(message "%s removed from list %s!" account list-name))))
@@ -1903,9 +1886,9 @@ INSTANCE is an instance domain name."
(response (mastodon-http--get-json
(if user
(mastodon-http--api "instance")
- (concat instance
- "/api/v1/instance"))
- nil
+ (concat instance "/api/v1/instance"))
+ nil ; params
+ nil ; silent
:vector)))
(when response
(let ((buf (get-buffer-create "*mastodon-instance*")))
@@ -2288,9 +2271,9 @@ For use after e.g. deleting a toot."
(if (member (buffer-name (current-buffer)) mastodon-tl--link-header-buffers)
;; link-header: can't build a URL with --more-json-async, endpoint/id:
(let* ((next (car (mastodon-tl--link-header)))
- ;(prev (cadr (mastodon-tl--link-header)))
+ ;;(prev (cadr (mastodon-tl--link-header)))
(url (mastodon-tl--build-link-header-url next)))
- (mastodon-http--get-response-async url 'mastodon-tl--more* (current-buffer)
+ (mastodon-http--get-response-async url nil 'mastodon-tl--more* (current-buffer)
(point) :headers))
(mastodon-tl--more-json-async (mastodon-tl--get-endpoint) (mastodon-tl--oldest-id)
'mastodon-tl--more* (current-buffer) (point))))
@@ -2491,9 +2474,9 @@ favourites."
(buffer (concat "*mastodon-" buffer-name "*")))
(if headers
(mastodon-http--get-response-async
- url 'mastodon-tl--init* buffer endpoint update-function headers)
+ url nil 'mastodon-tl--init* buffer endpoint update-function headers)
(mastodon-http--get-json-async
- url 'mastodon-tl--init* buffer endpoint update-function))))
+ url nil 'mastodon-tl--init* buffer endpoint update-function))))
(defun mastodon-tl--init* (response buffer endpoint update-function &optional headers)
"Initialize BUFFER with timeline targeted by ENDPOINT.
@@ -2547,16 +2530,16 @@ Runs synchronously.
Optional arg NOTE-TYPE means only get that type of note."
(let* ((exclude-types (when note-type
(mastodon-notifications--filter-types-list note-type)))
- (args (when note-type (mastodon-http--build-array-args-alist
+ (args (when note-type (mastodon-http--build-array-params-alist
"exclude_types[]" exclude-types)))
- (query-string (when note-type
- (mastodon-http--build-query-string args)))
+ ;; (query-string (when note-type
+ ;; (mastodon-http--build-params-string args)))
;; add note-type exclusions to endpoint so it works in `mastodon-tl--buffer-spec'
;; that way `mastodon-tl--more' works seamlessly too:
- (endpoint (if note-type (concat endpoint "?" query-string) endpoint))
+ ;; (endpoint (if note-type (concat endpoint "?" query-string) endpoint))
(url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*"))
- (json (mastodon-http--get-json url)))
+ (json (mastodon-http--get-json url args)))
(with-output-to-temp-buffer buffer
(switch-to-buffer buffer)
;; mastodon-mode wipes buffer-spec, so order must unforch be:
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 36d08fd..4f9fb1b 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -81,7 +81,7 @@
(autoload 'mastodon-profile--fetch-server-account-settings "mastodon-profile")
(autoload 'mastodon-tl--render-text "mastodon-tl")
(autoload 'mastodon-profile--fetch-server-account-settings-maybe "mastodon-profile")
-(autoload 'mastodon-http--build-array-args-alist "mastodon-http")
+(autoload 'mastodon-http--build-array-params-alist "mastodon-http")
(autoload 'mastodon-tl--get-endpoint "mastodon-tl")
(autoload 'mastodon-http--put "mastodon-http")
@@ -233,6 +233,7 @@ send.")
NO-TOOT means we are not calling from a toot buffer."
(mastodon-http--get-json-async
(mastodon-http--api "instance")
+ nil
'mastodon-toot--get-max-toot-chars-callback no-toot))
(defun mastodon-toot--get-max-toot-chars-callback (json-response
@@ -644,7 +645,7 @@ to `emojify-user-emojis', and the emoji data is updated."
(defun mastodon-toot--build-poll-params ()
"Return an alist of parameters for POSTing a poll status."
(append
- (mastodon-http--build-array-args-alist
+ (mastodon-http--build-array-params-alist
"poll[options][]"
(plist-get mastodon-toot-poll :options))
`(("poll[expires_in]" . ,(plist-get mastodon-toot-poll :expiry)))
@@ -678,7 +679,7 @@ instance to edit a toot."
("spoiler_text" . ,spoiler)
("language" . ,mastodon-toot--language)))
(args-media (when mastodon-toot--media-attachments
- (mastodon-http--build-array-args-alist
+ (mastodon-http--build-array-params-alist
"media_ids[]"
mastodon-toot--media-attachment-ids)))
(args-poll (when mastodon-toot-poll
@@ -743,7 +744,7 @@ instance to edit a toot."
(defun mastodon-toot--get-toot-source (id)
"Fetch the source JSON of toot with ID."
(let ((url (mastodon-http--api (format "/statuses/%s/source" id))))
- (mastodon-http--get-json url :silent)))
+ (mastodon-http--get-json url nil :silent)))
(defun mastodon-toot--get-toot-edits (id)
"Return the edit history of toot with ID."
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 04330f6..921e3af 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -313,8 +313,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 (concat "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))