diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-09-12 19:20:59 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-09-12 19:20:59 +0200 |
commit | c4ffff95371c25937bc61c86e72011a69fa3c078 (patch) | |
tree | 04a321fbcfff1891646dd431fb987db651eb20a5 | |
parent | cef2ed2bbb6aca680e40db4b14572227f3843eeb (diff) |
update meta fields (broken)
-rw-r--r-- | lisp/mastodon-profile.el | 36 |
1 files changed, 33 insertions, 3 deletions
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) |