aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-profile.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-09-11 14:43:50 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-09-11 14:43:50 +0200
commit12915775f8bec4c68f9b60b2851ecce75a84301a (patch)
tree0ddaa6e437b67a51cd915a3bdc994d2d0ec691ba /lisp/mastodon-profile.el
parent16acbea70362310985667a6eb65b60863f97448a (diff)
parenta986ec502a305a9a55311bec8956b1f0331d2b16 (diff)
Merge branch 'develop' into draft-toots
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r--lisp/mastodon-profile.el54
1 files changed, 39 insertions, 15 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 3065621..e8b8622 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -216,7 +216,7 @@ JSON is the data returned by the server."
(mastodon-search--insert-users-propertized json :note)))
;; (mastodon-profile--add-author-bylines json)))
-;;; account preferences
+;;; ACCOUNT PREFERENCES
(defun mastodon-profile--get-json-value (val)
"Fetch current VAL ue from account."
@@ -273,41 +273,48 @@ SOURCE means that the preference is in the 'source' part of the account json."
(response (mastodon-http--patch url `((,pref-formatted ,val)))))
(mastodon-http--triage response
(lambda ()
- (mastodon-profile-update-preference-alist pref val)
+ (mastodon-profile-fetch-server-account-settings)
(message "Account setting %s updated to %s!" pref val)))))
-(defun mastodon-profile-update-preference-alist (pref val)
+(defun mastodon-profile--get-pref (pref)
+ "Return PREF from `mastodon-profile-account-settings'."
+ (plist-get mastodon-profile-account-settings pref))
+
+(defun mastodon-profile-update-preference-plist (pref val)
"Set local account preference plist preference PREF to VAL.
This is done after changing the setting on the server."
- (setf (plist-get mastodon-profile-account-settings pref) val))
+ ;; TODO: convert all :json-false to nil and back again on sending
+ (setq mastodon-profile-account-settings
+ (plist-put mastodon-profile-account-settings pref val)))
(defun mastodon-profile-fetch-server-account-settings ()
"Fetch basic account settings from the server.
Store the values in `mastodon-profile-account-settings'.
Run in `mastodon-mode-hook'."
- ;; TODO: add some server settings like max_chars
- (let ((keys '(locked discoverable display_name))
- (source-keys '(privacy)))
- ;; (instance-keys '(max_toot_chars)))
+ (let ((keys '(locked discoverable display_name bot))
+ (source-keys '(privacy sensitive language)))
(mapc (lambda (k)
- (mastodon-profile-update-preference-alist
+ (mastodon-profile-update-preference-plist
k
(mastodon-profile--get-json-value k)))
keys)
(mapc (lambda (sk)
- (mastodon-profile-update-preference-alist
+ (mastodon-profile-update-preference-plist
sk
(mastodon-profile--get-source-pref sk)))
source-keys)
;; hack for max toot chars:
(mastodon-toot--get-max-toot-chars :no-toot)
- (mastodon-profile-update-preference-alist 'max_toot_chars
+ (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.
-Locked accounts mean follow requests have to be manually approved."
+Locked means follow requests have to be approved."
(interactive)
(mastodon-profile--toggle-account-key 'locked))
@@ -317,9 +324,24 @@ Discoverable means the account is listed in the server directory."
(interactive)
(mastodon-profile--toggle-account-key 'discoverable))
-(defun mastodon-profile--toggle-account-key (key)
- "Toggle the boolean account setting KEY."
- (let* ((val (mastodon-profile--get-json-value key))
+(defun mastodon-profile-account-bot-toggle ()
+ "Toggle the bot status of your account."
+ (interactive)
+ (mastodon-profile--toggle-account-key 'bot))
+
+;; TODO: actually respect "sensitive" account setting
+(defun mastodon-profile-account-sensitive-toggle ()
+ "Toggle the sensitive status of your account.
+When enabled, statuses are marked as sensitive by default."
+ (interactive)
+ (mastodon-profile--toggle-account-key 'sensitive))
+
+(defun mastodon-profile--toggle-account-key (key &optional source)
+ "Toggle the boolean account setting KEY.
+SOURCE means the setting is located under \"source\" in the account JSON."
+ (let* ((val (if source
+ (mastodon-profile--get-source-pref key)
+ (mastodon-profile--get-json-value key)))
(prompt (format "Account setting %s is %s. Toggle?" key val)))
(if (not (equal val :json-false))
(when (y-or-n-p prompt)
@@ -360,6 +382,8 @@ Discoverable means the account is listed in the server directory."
"\n\n"))))
(goto-char (point-min)))))
+;; PROFILE VIEW DETAILS
+
(defun mastodon-profile--relationships-get (id)
"Fetch info about logged-in user's relationship to user with id ID."
(let* ((their-id id)