aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-09-12 09:52:11 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-09-12 09:52:11 +0200
commit759267c593d88fcce453212b0a8a2892bb90ea8f (patch)
treebfd9687fbd6bdd8f1dd31ae7ba8c0c6efac51c90
parent160aefb2fe03f101f9f137abe8da4f81eed5f7a5 (diff)
parente7209bd1d404324cf5653b2728c1d219902e8f29 (diff)
Merge branch 'develop' into draft-toots
-rw-r--r--README.org2
-rw-r--r--lisp/mastodon-profile.el37
-rw-r--r--lisp/mastodon-tl.el7
3 files changed, 22 insertions, 24 deletions
diff --git a/README.org b/README.org
index 157e342..5288bb0 100644
--- a/README.org
+++ b/README.org
@@ -225,6 +225,8 @@ You can download and use your instance's custom emoji
- =mastodon-profile-set-default-toot-visibility=: Set the default visibility for your toots.
- =mastodon-profile-account-locked-toggle=: Toggle the locked status of your account. Locked accounts have to manually approve follow requests.
- =mastodon-profile-account-discoverable-toggle=: Toggle the discoverable status of your account. Non-discoverable accounts are not listed in the profile directory.
+- =mastodon-profile-account-bot-toggle=: Toggle whether your account is flagged as a bot.
+- =mastodon-profile-account-sensitive-toggle=: Toggle whether your posts are marked as sensitive (nsfw) by default.
*** Customization
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index e8b8622..3b6f336 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -120,7 +120,11 @@ extra keybindings."
"Keymap for `mastodon-profile-update-mode'.")
(persist-defvar mastodon-profile-account-settings nil
- "An alist of account settings saved from the server.")
+ "An alist of account settings saved from the server.
+Other clients can change these settings on the server at any
+time, so this list is not the canonical source for settings. It
+is updated on entering mastodon mode and on toggle any setting it
+contains")
(define-minor-mode mastodon-profile-update-mode
"Minor mode to update Mastodon user profile."
@@ -224,13 +228,13 @@ JSON is the data returned by the server."
(response (mastodon-http--get-json url)))
(alist-get val response)))
-(defun mastodon-profile--get-source-prefs ()
+(defun mastodon-profile--get-source-values ()
"Return the \"source\" preferences from the server."
(mastodon-profile--get-json-value 'source))
-(defun mastodon-profile--get-source-pref (pref)
+(defun mastodon-profile--get-source-value (pref)
"Return account PREF erence from the \"source\" section on the server."
- (let ((source (mastodon-profile--get-source-prefs)))
+ (let ((source (mastodon-profile--get-source-values)))
(alist-get pref source)))
(defun mastodon-profile--update-user-profile-note ()
@@ -265,9 +269,9 @@ JSON is the data returned by the server."
(lambda () (message "Profile note updated!"))))))
(defun mastodon-profile--update-preference (pref val &optional source)
- "Update a single acount PREF erence to setting VAL.
+ "Update account PREF erence to setting VAL.
Both args are strings.
-SOURCE means that the preference is in the 'source' part of the account json."
+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)))))
@@ -283,7 +287,6 @@ SOURCE means that the preference is in the 'source' part of the account json."
(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."
- ;; 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)))
@@ -301,7 +304,7 @@ Run in `mastodon-mode-hook'."
(mapc (lambda (sk)
(mastodon-profile-update-preference-plist
sk
- (mastodon-profile--get-source-pref sk)))
+ (mastodon-profile--get-source-value sk)))
source-keys)
;; hack for max toot chars:
(mastodon-toot--get-max-toot-chars :no-toot)
@@ -329,28 +332,28 @@ Discoverable means the account is listed in the server directory."
(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))
+ (mastodon-profile--toggle-account-key 'sensitive :source))
(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."
+SOURCE means the setting is located under \"source\" in the account JSON.
+Current settings are fetched from the server."
(let* ((val (if source
- (mastodon-profile--get-source-pref key)
+ (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))
(when (y-or-n-p prompt)
- (mastodon-profile--update-preference (symbol-name key) "false"))
+ (mastodon-profile--update-preference (symbol-name key) "false" source))
(when (y-or-n-p prompt)
- (mastodon-profile--update-preference (symbol-name key) "true")))))
+ (mastodon-profile--update-preference (symbol-name key) "true" source)))))
-(defun mastodon-profile--edit-account-string (key)
- "Edit the string for account setting KEY."
+(defun mastodon-profile--edit-string-value (key)
+ "Edit the string for account preference KEY."
(let* ((val (mastodon-profile--get-json-value key))
(new-val
(read-string (format "Edit account setting %s: " key)
@@ -360,7 +363,7 @@ SOURCE means the setting is located under \"source\" in the account JSON."
(defun mastodon-profile-update-display-name ()
"Update display name for your account."
(interactive)
- (mastodon-profile--edit-account-string 'display_name))
+ (mastodon-profile--edit-string-value 'display_name))
(defun mastodon-profile-view-preferences ()
"View user preferences in another window."
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index db8ce20..d8b2baa 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1175,13 +1175,6 @@ webapp"
(reblog (alist-get 'reblog json)))
(if reblog (alist-get 'id reblog) id)))
-(defun mastodon-tl--single-toot-from-url (url)
- "Open the toot at URL in `mastodon.el'."
- ;; TODO: test if URL is masto
- ;; FIXME: this only works 1/2 the time
- (let ((id (url-file-nondirectory url)))
- (mastodon-tl--single-toot id)))
-
(defun mastodon-tl--single-toot (&optional id)
"View toot at point in separate buffer.
ID is that of the toot to view."