diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-10-30 11:13:44 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-10-30 11:15:45 +0100 |
commit | 075f1f9ba41100a0fb3161598065a55bf09aaedd (patch) | |
tree | c42a4dc39cfb6fd842f985ac7009ae5f5c7714ff /lisp/mastodon-profile.el | |
parent | ddfa5275dfc10a555269ddb69aa91cd15cf3973b (diff) |
re-write --make-meta-fields-params to build normal params alist
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r-- | lisp/mastodon-profile.el | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 6724038..33c4181 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -365,35 +365,31 @@ Current settings are fetched from the server." (interactive) (mastodon-profile--edit-string-value 'display_name)) -;; TODO: ideally this would return an alist to use like normal params (defun mastodon-profile--make-meta-fields-params (fields) "Construct a parameter query string from metadata alist FIELDS." - (let ((count 0) - (loop-list (cl-loop for x in fields - for count from 0 to 4 - collect (concat - (format "fields_attributes[%s][name]" count) - "=" - (url-hexify-string (car x)) - "&" - (format "fields_attributes[%s][value]" count) - "=" - (url-hexify-string (cdr x)))))) - (mapconcat #'identity loop-list "&"))) + (let ((keys (cl-loop for count from 1 to 5 + collect (cons (format "fields_attributes[%s][name]" count) + (format "fields_attributes[%s][value]" count))))) + (cl-loop for a-pair in keys + for b-pair in fields + append (list (cons (car a-pair) + (car b-pair)) + (cons (cdr a-pair) + (cdr b-pair)))))) (defun mastodon-profile-update-meta-fields () "Prompt for new metadata fields information and PATCH the server." (interactive) (let* ((url (mastodon-http--api "accounts/update_credentials")) - (fields-updated (or data (mastodon-profile--update-meta-fields-alist))) - (param-str (mastodon-profile--make-meta-fields-params fields-updated)) - (response (mastodon-http--patch url param-str :no-build))) - (setq test-fields-str param-str) + (fields-updated (mastodon-profile--update-meta-fields-alist)) + (params (mastodon-profile--make-meta-fields-params fields-updated)) + (response (mastodon-http--patch url params))) + (setq test-fields-str params) (mastodon-http--triage response (lambda () (mastodon-profile-fetch-server-account-settings) (message "Account setting %s updated to %s!" - "metadata fields" params))))) + "metadata fields" fields-updated))))) (defun mastodon-profile--update-meta-fields-alist () "Prompt for new metadata fields information." |