diff options
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r-- | lisp/mastodon-profile.el | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 3b6f336..ff729f0 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -274,7 +274,7 @@ Both args are strings. SOURCE means that the preference is in the 'source' part of the account JSON." (let* ((url (mastodon-http--api "accounts/update_credentials")) (pref-formatted (if source (concat "source[" pref "]") pref)) - (response (mastodon-http--patch url `((,pref-formatted ,val))))) + (response (mastodon-http--patch url `((,pref-formatted . ,val))))) (mastodon-http--triage response (lambda () (mastodon-profile-fetch-server-account-settings) @@ -365,6 +365,15 @@ Current settings are fetched from the server." (interactive) (mastodon-profile--edit-string-value 'display_name)) +(defun mastodon-profile--get-preferences-pref (pref) + "Fetch PREF from the endpoint \"/preferences\". +This endpoint only holds a few preferences. For others, see +`mastodon-profile--update-preference' and its endpoint, +\"/accounts/update_credentials.\"" + (alist-get pref + (mastodon-http--get-json + (mastodon-http--api "preferences")))) + (defun mastodon-profile-view-preferences () "View user preferences in another window." (interactive) @@ -397,11 +406,11 @@ Current settings are fetched from the server." (defun mastodon-profile--fields-get (account) "Fetch the fields vector (aka profile metadata) from profile of ACCOUNT. -Returns a list of lists." +Returns an alist." (let ((fields (mastodon-profile--account-field account 'fields))) (when fields (mapcar (lambda (el) - (list (alist-get 'name el) + (cons (alist-get 'name el) (alist-get 'value el))) fields)))) @@ -415,7 +424,7 @@ Returns a list of lists." (concat (format "_ %s " (car field)) (make-string (- (+ 1 left-width) (length (car field))) ?_) - (format " :: %s" (cadr field))) + (format " :: %s" (cdr field))) field)) ; hack to make links tabstops fields ""))) @@ -477,30 +486,33 @@ Returns a list of lists." (is-followers " FOLLOWERS ") (is-following " FOLLOWING ")))) (insert - "\n" - (mastodon-profile--image-from-account account) - "\n" - (propertize (mastodon-profile--account-field - account 'display_name) - 'face 'mastodon-display-name-face) - "\n" - (propertize (concat "@" acct) - 'face 'default) - (if (equal locked t) - (if (fontp (char-displayable-p #10r9993)) - " 🔒" - " [locked]") - "") - "\n ------------\n" - (mastodon-tl--render-text note account) - ;; account here to enable tab-stops in profile note - (if fields - (concat "\n" - (mastodon-tl--set-face - (mastodon-profile--fields-insert fields) - 'success) - "\n") - "") + (propertize + (concat + "\n" + (mastodon-profile--image-from-account account) + "\n" + (propertize (mastodon-profile--account-field + account 'display_name) + 'face 'mastodon-display-name-face) + "\n" + (propertize (concat "@" acct) + 'face 'default) + (if (equal locked t) + (if (fontp (char-displayable-p #10r9993)) + " 🔒" + " [locked]") + "") + "\n ------------\n" + (mastodon-tl--render-text note account) + ;; account here to enable tab-stops in profile note + (if fields + (concat "\n" + (mastodon-tl--set-face + (mastodon-profile--fields-insert fields) + 'success) + "\n") + "")) + 'profile-json account) ;; insert counts (mastodon-tl--set-face (concat " ------------\n" |