aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
authorSkylar Hill <stellarskylark@posteo.net>2022-12-08 22:55:05 -0600
committerSkylar Hill <stellarskylark@posteo.net>2022-12-08 22:55:05 -0600
commitf238a32c5bbe3131efb7c53a6f89f9f217eac4e0 (patch)
treeadcee94639770b07e51c22e4c6dd1c880f865289 /lisp/mastodon-tl.el
parent8db62b46a141dc862cee6e90afc935964a55b9d4 (diff)
mastodon-tl--spoiler: Add error handling to /preferences api query
mastodon.el currently breaks when trying to load a spoilered toot if the /preferences endpoint returns something unexpected, preventing mastodon-tl--buffer-spec from being set and not automatically enabling the major mode. This is particularly a problem on GoToSocial, which does not currently have the endpoint implemented and instead returns a 404 HTML page, causing a JSON parsing error. This PR adds a simple check which causes the API check in mastodon-tl--spoiler to return null if it errors, thus triggering the default behavior of hiding CW'd toots until opened.
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el8
1 files changed, 6 insertions, 2 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index e732420..41368e8 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1044,8 +1044,12 @@ message is a link which unhides/hides the main body."
'invisible
;; check server setting to expand all spoilers:
(unless (eq t
- (mastodon-profile--get-preferences-pref
- 'reading:expand:spoilers))
+ ;; If something goes wrong reading prefs,
+ ;; just return nil so CWs show by default.
+ (condition-case nil
+ (mastodon-profile--get-preferences-pref
+ 'reading:expand:spoilers)
+ (error nil)))
t)
'mastodon-content-warning-body t))))