aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2022-01-15 18:55:26 +0100
committermousebot <mousebot@riseup.net>2022-01-15 18:55:26 +0100
commit5994d01cf15800f274206819145cbf7ba176a007 (patch)
tree1feb2fb00c2c67e4cfd6e92f5702531aa56b8d9f
parent70546e4fd9951b31685a9063653b72b3ce6e44db (diff)
handle a buggy empty notification
i received an notification (also in other clients/web interface) attached to no toot. these checks should allow notifications view to display without tripping up on any such vacant notifs from the server.
-rw-r--r--lisp/mastodon-notifications.el3
-rw-r--r--lisp/mastodon-tl.el35
2 files changed, 20 insertions, 18 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index c245edb..77d40a8 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -223,7 +223,8 @@ takes a single function. By default it is
`mastodon-tl--byline-boosted'.
ID is the notification's own id, which is attached as a property."
- (mastodon-tl--insert-status toot body author-byline action-byline id))
+ (when toot ; handle rare blank notif server bug
+ (mastodon-tl--insert-status toot body author-byline action-byline id)))
(defun mastodon-notifications--by-type (note)
"Filters NOTE for those listed in `mastodon-notifications--types-alist'."
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index cd27bd5..9b30a37 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -460,22 +460,23 @@ By default it is `mastodon-tl--byline-boosted'"
The contents comes from the given TOOT which is used in parsing
links in the text. If TOOT is nil no parsing occurs."
- (with-temp-buffer
- (insert string)
- (let ((shr-use-fonts mastodon-tl--enable-proportional-fonts)
- (shr-width (when mastodon-tl--enable-proportional-fonts
- (- (window-width) 1))))
- (shr-render-region (point-min) (point-max)))
- ;; Make all links a tab stop recognized by our own logic, make things point
- ;; to our own logic (e.g. hashtags), and update keymaps where needed:
- (when toot
- (let (region)
- (while (setq region (mastodon-tl--find-property-range
- 'shr-url (or (cdr region) (point-min))))
- (mastodon-tl--process-link toot
- (car region) (cdr region)
- (get-text-property (car region) 'shr-url)))))
- (buffer-string)))
+ (when string ; handle rare empty notif server bug
+ (with-temp-buffer
+ (insert string)
+ (let ((shr-use-fonts mastodon-tl--enable-proportional-fonts)
+ (shr-width (when mastodon-tl--enable-proportional-fonts
+ (- (window-width) 1))))
+ (shr-render-region (point-min) (point-max)))
+ ;; Make all links a tab stop recognized by our own logic, make things point
+ ;; to our own logic (e.g. hashtags), and update keymaps where needed:
+ (when toot
+ (let (region)
+ (while (setq region (mastodon-tl--find-property-range
+ 'shr-url (or (cdr region) (point-min))))
+ (mastodon-tl--process-link toot
+ (car region) (cdr region)
+ (get-text-property (car region) 'shr-url)))))
+ (buffer-string))))
(defun mastodon-tl--process-link (toot start end url)
"Process link URL in TOOT as hashtag, userhandle, or normal link.
@@ -1090,7 +1091,7 @@ NOTIFY is only non-nil when called by `mastodon-tl--follow-user'."
;; if unmuting/unblocking, we got handle from mute/block list
(mastodon-profile--search-account-by-handle
user-handle)
- ;; if muting/blocking, we select from handles in current status
+ ;; if muting/blocking, we select from handles in current status
(mastodon-profile--lookup-account-in-status
user-handle (mastodon-profile--toot-json))))
(user-id (mastodon-profile--account-field account 'id))