From c4ffff95371c25937bc61c86e72011a69fa3c078 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 19:20:59 +0200 Subject: update meta fields (broken) --- lisp/mastodon-profile.el | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 38aceae..87e467c 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -404,10 +404,40 @@ This endpoint only holds a few preferences. For others, see their-id)))) (mastodon-http--get-json url))) -(defun mastodon-profile--fields-get (account) +(defun mastodon-profile-update-meta-fields () + "" + (interactive) + (let* ((fields-updated (mastodon-profile--update-meta-fields-alist)) + (fields-json (json-encode + (mapcar (lambda (x) + (list (cons 'name (car x)) + (cons 'value (cdr x)) + (cons 'verified_at nil))) + fields-updated)))) + (mastodon-profile--update-preference 'fields_attributes fields-json))) + +(defun mastodon-profile--update-meta-fields-alist () + "" + (let ((fields-old + (mastodon-profile--fields-get + nil + ;; we must fetch the plaintext version: + (mastodon-profile--get-source-pref 'fields))) + fields-new) + (dolist (f fields-old (reverse fields-new)) + (push + (cons (read-string "Edit account metadata key: " + (car f)) + (read-string "Edit account metadata value: " + (cdr f))) + fields-new)))) + +(defun mastodon-profile--fields-get (&optional account fields) "Fetch the fields vector (aka profile metadata) from profile of ACCOUNT. -Returns an alist." - (let ((fields (mastodon-profile--account-field account 'fields))) +Returns an alist. +FIELDS means provide a fields vector fetched by other means." + (let ((fields (or fields + (mastodon-profile--account-field account 'fields)))) (when fields (mapcar (lambda (el) (cons (alist-get 'name el) -- cgit v1.2.3 From f7603638933ee7bb9bc7d9065eab15d186c5ca3c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 12 Sep 2022 21:40:22 +0200 Subject: format profile preference params to match toot-send ones --- lisp/mastodon-profile.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 87e467c..590f463 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) -- cgit v1.2.3 From f6b983e04fe3ac091398dd74cdbf3a986b969b2a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 29 Oct 2022 16:32:24 +0200 Subject: working meta fields update --- lisp/mastodon-http.el | 6 ++++-- lisp/mastodon-profile.el | 46 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 36 insertions(+), 16 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index f32ccd4..0491927 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -211,14 +211,16 @@ Optionally specify the PARAMS to send." (with-current-buffer (mastodon-http--patch url params) (mastodon-http--process-json))) -(defun mastodon-http--patch (base-url &optional params) +(defun mastodon-http--patch (base-url &optional params no-build) "Make synchronous PATCH request to BASE-URL. Optionally specify the PARAMS to send." (mastodon-http--authorized-request "PATCH" (let ((url (concat base-url "?" - (mastodon-http--build-query-string params)))) + (if no-build + params + (mastodon-http--build-query-string params))))) (mastodon-http--url-retrieve-synchronously url)))) ;; Asynchronous functions diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 590f463..6ecabb2 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -404,25 +404,43 @@ This endpoint only holds a few preferences. For others, see their-id)))) (mastodon-http--get-json url))) -(defun mastodon-profile-update-meta-fields () +;; TODO: ideally we wd make a nice alist of all these params +(defun mastodon-profile--make-meta-fields-params (fields) + "" + (let ((count 0) + 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)))))) + +(defun mastodon-profile-update-meta-fields (&optional data) "" (interactive) - (let* ((fields-updated (mastodon-profile--update-meta-fields-alist)) - (fields-json (json-encode - (mapcar (lambda (x) - (list (cons 'name (car x)) - (cons 'value (cdr x)) - (cons 'verified_at nil))) - fields-updated)))) - (mastodon-profile--update-preference 'fields_attributes fields-json))) + (let* ((url (mastodon-http--api "accounts/update_credentials")) + (fields-updated (or data(mastodon-profile--update-meta-fields-alist))) + (params (mastodon-profile--make-meta-fields-params fields-updated)) + (param-str (mapconcat #'identity params "&")) + (response (mastodon-http--patch url param-str :no-build))) + (setq test-fields-str param-str) + (mastodon-http--triage response + (lambda () + (mastodon-profile-fetch-server-account-settings) + (message "Account setting %s updated to %s!" + "metadata fields" params))))) (defun mastodon-profile--update-meta-fields-alist () "" - (let ((fields-old - (mastodon-profile--fields-get - nil - ;; we must fetch the plaintext version: - (mastodon-profile--get-source-pref 'fields))) + (let ((fields-old (mastodon-profile--fields-get + nil + ;; we must fetch the plaintext version: + (mastodon-profile--get-source-value 'fields))) fields-new) (dolist (f fields-old (reverse fields-new)) (push -- cgit v1.2.3 From 6458ec4e1ca4a5af9c065231884f67dc27264f10 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 29 Oct 2022 17:04:08 +0200 Subject: still prompt for empty fields, up to 4 display meta field number in prompt --- lisp/mastodon-profile.el | 95 +++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 46 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 0b35fa4..6724038 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -365,6 +365,55 @@ 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 "&"))) + +(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) + (mastodon-http--triage response + (lambda () + (mastodon-profile-fetch-server-account-settings) + (message "Account setting %s updated to %s!" + "metadata fields" params))))) + +(defun mastodon-profile--update-meta-fields-alist () + "Prompt for new metadata fields information." + (let ((fields-old (mastodon-profile--fields-get + nil + ;; we must fetch the plaintext version: + (mastodon-profile--get-source-value 'fields))) + fields-new) + ;; offer empty fields if user currently has less than four filled: + (while (< (length fields-old) 4) + (setq fields-old + (append fields-old '(("" . ""))))) + (cl-loop for f in fields-old + for x from 1 to 5 + collect + (cons (read-string (format "Edit account metadata key [%s/4]: " x) + (car f)) + (read-string (format "Edit account metadata value [%s/4]: " x) + (cdr f)))))) + (defun mastodon-profile--get-preferences-pref (pref) "Fetch PREF from the endpoint \"/preferences\". This endpoint only holds a few preferences. For others, see @@ -404,52 +453,6 @@ This endpoint only holds a few preferences. For others, see their-id)))) (mastodon-http--get-json url))) -;; TODO: ideally we wd make a nice alist of all these params -(defun mastodon-profile--make-meta-fields-params (fields) - "" - (let ((count 0) - 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)))))) - -(defun mastodon-profile-update-meta-fields (&optional data) - "" - (interactive) - (let* ((url (mastodon-http--api "accounts/update_credentials")) - (fields-updated (or data(mastodon-profile--update-meta-fields-alist))) - (params (mastodon-profile--make-meta-fields-params fields-updated)) - (param-str (mapconcat #'identity params "&")) - (response (mastodon-http--patch url param-str :no-build))) - (setq test-fields-str param-str) - (mastodon-http--triage response - (lambda () - (mastodon-profile-fetch-server-account-settings) - (message "Account setting %s updated to %s!" - "metadata fields" params))))) - -(defun mastodon-profile--update-meta-fields-alist () - "" - (let ((fields-old (mastodon-profile--fields-get - nil - ;; we must fetch the plaintext version: - (mastodon-profile--get-source-value 'fields))) - fields-new) - (dolist (f fields-old (reverse fields-new)) - (push - (cons (read-string "Edit account metadata key: " - (car f)) - (read-string "Edit account metadata value: " - (cdr f))) - fields-new)))) - (defun mastodon-profile--fields-get (&optional account fields) "Fetch the fields vector (aka profile metadata) from profile of ACCOUNT. Returns an alist. -- cgit v1.2.3 From 075f1f9ba41100a0fb3161598065a55bf09aaedd Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 30 Oct 2022 11:13:44 +0100 Subject: re-write --make-meta-fields-params to build normal params alist --- lisp/mastodon-http.el | 6 ++---- lisp/mastodon-profile.el | 32 ++++++++++++++------------------ 2 files changed, 16 insertions(+), 22 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 0491927..f32ccd4 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -211,16 +211,14 @@ Optionally specify the PARAMS to send." (with-current-buffer (mastodon-http--patch url params) (mastodon-http--process-json))) -(defun mastodon-http--patch (base-url &optional params no-build) +(defun mastodon-http--patch (base-url &optional params) "Make synchronous PATCH request to BASE-URL. Optionally specify the PARAMS to send." (mastodon-http--authorized-request "PATCH" (let ((url (concat base-url "?" - (if no-build - params - (mastodon-http--build-query-string params))))) + (mastodon-http--build-query-string params)))) (mastodon-http--url-retrieve-synchronously url)))) ;; Asynchronous functions 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." -- cgit v1.2.3 From 31b42363969ac5fbcba444c59c32dd142054bbd9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 30 Oct 2022 11:53:19 +0100 Subject: docstrings --- lisp/mastodon-profile.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 33c4181..505dbc4 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -366,7 +366,8 @@ Current settings are fetched from the server." (mastodon-profile--edit-string-value 'display_name)) (defun mastodon-profile--make-meta-fields-params (fields) - "Construct a parameter query string from metadata alist FIELDS." + "Construct a parameter query string from metadata alist FIELDS. +Returns an alist." (let ((keys (cl-loop for count from 1 to 5 collect (cons (format "fields_attributes[%s][name]" count) (format "fields_attributes[%s][value]" count))))) @@ -392,7 +393,8 @@ Current settings are fetched from the server." "metadata fields" fields-updated))))) (defun mastodon-profile--update-meta-fields-alist () - "Prompt for new metadata fields information." + "Prompt for new metadata fields information. +Returns the results as an alist." (let ((fields-old (mastodon-profile--fields-get nil ;; we must fetch the plaintext version: -- cgit v1.2.3 From 2fb09762a4150d6a14fb3217b2debef948df6ff9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 30 Oct 2022 13:05:08 +0100 Subject: hack to limit meta fields to 255 w/o using string-limit --- lisp/mastodon-profile.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 505dbc4..d6819db 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -385,7 +385,6 @@ Returns an alist." (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) @@ -398,19 +397,30 @@ Returns the results as an alist." (let ((fields-old (mastodon-profile--fields-get nil ;; we must fetch the plaintext version: - (mastodon-profile--get-source-value 'fields))) - fields-new) + (mastodon-profile--get-source-value 'fields)))) ;; offer empty fields if user currently has less than four filled: (while (< (length fields-old) 4) (setq fields-old (append fields-old '(("" . ""))))) - (cl-loop for f in fields-old - for x from 1 to 5 - collect - (cons (read-string (format "Edit account metadata key [%s/4]: " x) - (car f)) - (read-string (format "Edit account metadata value [%s/4]: " x) - (cdr f)))))) + (let ((alist + (cl-loop for f in fields-old + for x from 1 to 5 + collect + (cons (read-string + (format "Metadata key [%s/4] (max. 255 chars): " x) + (car f)) + (read-string + (format "Metadata value [%s/4] (max. 255 chars): " x) + (cdr f)))))) + ;; hack to avoiding using `string-limit', which req. 28.1: + (mapcar (lambda (x) + (cons (mastodon-profile--limit-to-255 (car x)) + (mastodon-profile--limit-to-255 (cdr x)))) + alist)))) + +(defun mastodon-profile--limit-to-255 (x) + "Limit string X to 255 chars max." + (if (> (length x) 255) (substring x 0 255) x)) (defun mastodon-profile--get-preferences-pref (pref) "Fetch PREF from the endpoint \"/preferences\". -- cgit v1.2.3 From 36382243a2a9278837a63d677cb94203bd01ad6a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 30 Oct 2022 13:09:56 +0100 Subject: defvars for flycheck --- lisp/mastodon-profile.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index d6819db..cfb3bdb 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -74,6 +74,8 @@ (defvar mastodon-tl--update-point) (defvar mastodon-mode-map) (defvar mastodon-toot--max-toot-chars) +(defvar mastodon-toot--visibility) +(defvar mastodon-toot--content-nsfw) (defvar-local mastodon-profile--account nil "The data for the account being described in the current profile buffer.") -- cgit v1.2.3 From 42990b2a471afc2d4cc1102f8cec8e70982f2e2c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 5 Nov 2022 15:40:46 +0100 Subject: fetch-server-account-settings: only fetch if var not set --- lisp/mastodon-profile.el | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index cfb3bdb..c6aa5e2 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -296,26 +296,27 @@ This is done after changing the setting on the server." "Fetch basic account settings from the server. Store the values in `mastodon-profile-account-settings'. Run in `mastodon-mode-hook'." - (let ((keys '(locked discoverable display_name bot)) - (source-keys '(privacy sensitive language))) - (mapc (lambda (k) - (mastodon-profile-update-preference-plist - k - (mastodon-profile--get-json-value k))) - keys) - (mapc (lambda (sk) - (mastodon-profile-update-preference-plist - sk - (mastodon-profile--get-source-value sk))) - source-keys) - ;; hack for max toot chars: - (mastodon-toot--get-max-toot-chars :no-toot) - (mastodon-profile-update-preference-plist 'max_toot_chars - mastodon-toot--max-toot-chars) - ;; TODO: remove now redundant vars, replace with fetchers from the plist - (setq mastodon-toot--visibility (mastodon-profile--get-pref 'privacy) - mastodon-toot--content-nsfw (mastodon-profile--get-pref 'sensitive)) - mastodon-profile-account-settings)) + (unless mastodon-profile-account-settings + (let ((keys '(locked discoverable display_name bot)) + (source-keys '(privacy sensitive language))) + (mapc (lambda (k) + (mastodon-profile-update-preference-plist + k + (mastodon-profile--get-json-value k))) + keys) + (mapc (lambda (sk) + (mastodon-profile-update-preference-plist + sk + (mastodon-profile--get-source-value sk))) + source-keys) + ;; hack for max toot chars: + (mastodon-toot--get-max-toot-chars :no-toot) + (mastodon-profile-update-preference-plist 'max_toot_chars + mastodon-toot--max-toot-chars) + ;; TODO: remove now redundant vars, replace with fetchers from the plist + (setq mastodon-toot--visibility (mastodon-profile--get-pref 'privacy) + mastodon-toot--content-nsfw (mastodon-profile--get-pref 'sensitive)) + mastodon-profile-account-settings))) (defun mastodon-profile-account-locked-toggle () "Toggle the locked status of your account. -- cgit v1.2.3 From 0f85f3d69066a48434a6b27c4cbb77aa976984e9 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 31 Oct 2022 11:35:00 +0100 Subject: convert :json-false to nil in account settings handling :json-false isn't nil, so doesn't work as we want --- lisp/mastodon-profile.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index c6aa5e2..55e7d42 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -228,7 +228,9 @@ JSON is the data returned by the server." "Fetch current VAL ue from account." (let* ((url (mastodon-http--api "accounts/verify_credentials")) (response (mastodon-http--get-json url))) - (alist-get val response))) + (if (eq (alist-get val response) ':json-false) + nil + (alist-get val response)))) (defun mastodon-profile--get-source-values () "Return the \"source\" preferences from the server." @@ -237,7 +239,9 @@ JSON is the data returned by the server." (defun mastodon-profile--get-source-value (pref) "Return account PREF erence from the \"source\" section on the server." (let ((source (mastodon-profile--get-source-values))) - (alist-get pref source))) + (if (eq (alist-get pref source) ':json-false) + nil + (alist-get pref source)))) (defun mastodon-profile--update-user-profile-note () "Fetch user's profile note and display for editing." @@ -349,7 +353,7 @@ Current settings are fetched from the server." (mastodon-profile--get-source-value key) (mastodon-profile--get-json-value key))) (prompt (format "Account setting %s is %s. Toggle?" key val))) - (if (not (equal val :json-false)) + (if val (when (y-or-n-p prompt) (mastodon-profile--update-preference (symbol-name key) "false" source)) (when (y-or-n-p prompt) -- cgit v1.2.3 From 6556a83fa6bc67c5c44022ab9c2334ef7ffe5549 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 5 Nov 2022 15:43:35 +0100 Subject: Revert "fetch-server-account-settings: only fetch if var not set" This reverts commit 42990b2a471afc2d4cc1102f8cec8e70982f2e2c. --- lisp/mastodon-profile.el | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 55e7d42..4aa9310 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -300,27 +300,26 @@ This is done after changing the setting on the server." "Fetch basic account settings from the server. Store the values in `mastodon-profile-account-settings'. Run in `mastodon-mode-hook'." - (unless mastodon-profile-account-settings - (let ((keys '(locked discoverable display_name bot)) - (source-keys '(privacy sensitive language))) - (mapc (lambda (k) - (mastodon-profile-update-preference-plist - k - (mastodon-profile--get-json-value k))) - keys) - (mapc (lambda (sk) - (mastodon-profile-update-preference-plist - sk - (mastodon-profile--get-source-value sk))) - source-keys) - ;; hack for max toot chars: - (mastodon-toot--get-max-toot-chars :no-toot) - (mastodon-profile-update-preference-plist 'max_toot_chars - mastodon-toot--max-toot-chars) - ;; TODO: remove now redundant vars, replace with fetchers from the plist - (setq mastodon-toot--visibility (mastodon-profile--get-pref 'privacy) - mastodon-toot--content-nsfw (mastodon-profile--get-pref 'sensitive)) - mastodon-profile-account-settings))) + (let ((keys '(locked discoverable display_name bot)) + (source-keys '(privacy sensitive language))) + (mapc (lambda (k) + (mastodon-profile-update-preference-plist + k + (mastodon-profile--get-json-value k))) + keys) + (mapc (lambda (sk) + (mastodon-profile-update-preference-plist + sk + (mastodon-profile--get-source-value sk))) + source-keys) + ;; hack for max toot chars: + (mastodon-toot--get-max-toot-chars :no-toot) + (mastodon-profile-update-preference-plist 'max_toot_chars + mastodon-toot--max-toot-chars) + ;; TODO: remove now redundant vars, replace with fetchers from the plist + (setq mastodon-toot--visibility (mastodon-profile--get-pref 'privacy) + mastodon-toot--content-nsfw (mastodon-profile--get-pref 'sensitive)) + mastodon-profile-account-settings)) (defun mastodon-profile-account-locked-toggle () "Toggle the locked status of your account. -- cgit v1.2.3