aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-profile.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-10-30 13:05:08 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-10-30 13:09:51 +0100
commit2fb09762a4150d6a14fb3217b2debef948df6ff9 (patch)
treeb09a7a9e3caaf482a7b23dadf23f2a3f208df1e7 /lisp/mastodon-profile.el
parent31b42363969ac5fbcba444c59c32dd142054bbd9 (diff)
hack to limit meta fields to 255 w/o using string-limit
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r--lisp/mastodon-profile.el30
1 files changed, 20 insertions, 10 deletions
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\".