aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-08-09 14:13:24 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-08-16 08:47:04 +0200
commit9778bf022660ddb5a445e8538cd49b8e94fa7003 (patch)
tree341f54a704dcceea62c5e41eaf0a4e40a52b3f07
parent4c7fc8b47517249a271d64e104f68cf59048e872 (diff)
apply filters to notifications. #575.
-rw-r--r--lisp/mastodon-notifications.el149
1 files changed, 77 insertions, 72 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 22c702b..9f92172 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -214,80 +214,85 @@ Status notifications are given when
(string-limit str mastodon-notifications--profile-note-in-foll-reqs-max-length)
str))))
(status (mastodon-tl--field 'status note))
- (follower (alist-get 'username (alist-get 'account note))))
- (mastodon-notifications--insert-status
- ;; toot
- (cond ((or (equal type 'follow)
- (equal type 'follow-request))
- ;; Using reblog with an empty id will mark this as something
- ;; non-boostable/non-favable.
- (cons '(reblog (id . nil)) note))
- ;; reblogs/faves use 'note' to process their own json
- ;; not the toot's. this ensures following etc. work on such notifs
- ((or (equal type 'favourite)
- (equal type 'boost))
- note)
- (t
- status))
- ;; body
- (let ((body (mastodon-tl--clean-tabs-and-nl
- (if (mastodon-tl--has-spoiler status)
- (mastodon-tl--spoiler status)
- (if (equal 'follow-request type)
- (mastodon-tl--render-text profile-note)
- (mastodon-tl--content status))))))
- (cond ((or (eq type 'follow)
- (eq type 'follow-request))
- (propertize
- (if (equal type 'follow)
+ (follower (alist-get 'username (alist-get 'account note)))
+ (toot (alist-get 'status note))
+ (filtered (mastodon-tl--field 'filtered toot))
+ (filters (when filtered
+ (mastodon-tl--current-filters filtered))))
+ (if (and filtered (assoc "hide" filters))
+ nil
+ (mastodon-tl--insert-status
+ ;; toot
+ (cond ((or (equal type 'follow)
+ (equal type 'follow-request))
+ ;; Using reblog with an empty id will mark this as something
+ ;; non-boostable/non-favable.
+ (cons '(reblog (id . nil)) note))
+ ;; reblogs/faves use 'note' to process their own json
+ ;; not the toot's. this ensures following etc. work on such notifs
+ ((or (equal type 'favourite)
+ (equal type 'boost))
+ note)
+ (t
+ status))
+ ;; body
+ (let ((body (if-let ((match (assoc "warn" filters)))
+ (mastodon-tl--spoiler toot (cadr match))
+ (mastodon-tl--clean-tabs-and-nl
+ (if (mastodon-tl--has-spoiler status)
+ (mastodon-tl--spoiler status)
+ (if (equal 'follow-request type)
+ (mastodon-tl--render-text profile-note)
+ (mastodon-tl--content status)))))))
+ (cond ((or (eq type 'follow)
+ (eq type 'follow-request))
+ (if (equal type 'follow)
+ (propertize "Congratulations, you have a new follower!"
+ 'face 'default)
+ (concat
(propertize
- "Congratulations, you have a new follower!"
+ (format "You have a follow request from... %s"
+ follower)
'face 'default)
- (concat
- (propertize
- (format "You have a follow request from... %s"
- follower)
- 'face 'default)
- (when mastodon-notifications--profile-note-in-foll-reqs
- (concat
- ":\n"
- (mastodon-notifications--comment-note-text body)))))))
- ((or (eq type 'favourite)
- (eq type 'boost))
- (mastodon-notifications--comment-note-text
- body))
- (t body)))
- ;; author-byline
- (if (or (equal type 'follow)
- (equal type 'follow-request)
- (equal type 'mention))
- 'mastodon-tl--byline-author
- (lambda (_status &rest _args) ; unbreak stuff
- (mastodon-tl--byline-author note)))
- ;; action-byline
- (lambda (_status)
- (mastodon-notifications--byline-concat
- (cond ((equal type 'boost)
- "Boosted")
- ((equal type 'favourite)
- "Favourited")
- ((equal type 'follow-request)
- "Requested to follow")
- ((equal type 'follow)
- "Followed")
- ((equal type 'mention)
- "Mentioned")
- ((equal type 'status)
- "Posted")
- ((equal type 'poll)
- "Posted a poll")
- ((equal type 'edit)
- "Edited"))))
- id
- ;; base toot
- (when (or (equal type 'favourite)
- (equal type 'boost))
- status))))
+ (when mastodon-notifications--profile-note-in-foll-reqs
+ (concat
+ ":\n"
+ (mastodon-notifications--comment-note-text body))))))
+ ((or (eq type 'favourite)
+ (eq type 'boost))
+ (mastodon-notifications--comment-note-text body))
+ (t body)))
+ ;; author-byline
+ (if (or (equal type 'follow)
+ (equal type 'follow-request)
+ (equal type 'mention))
+ 'mastodon-tl--byline-author
+ (lambda (_status &rest _args) ; unbreak stuff
+ (mastodon-tl--byline-author note)))
+ ;; action-byline
+ (lambda (_status)
+ (mastodon-notifications--byline-concat
+ (cond ((equal type 'boost)
+ "Boosted")
+ ((equal type 'favourite)
+ "Favourited")
+ ((equal type 'follow-request)
+ "Requested to follow")
+ ((equal type 'follow)
+ "Followed")
+ ((equal type 'mention)
+ "Mentioned")
+ ((equal type 'status)
+ "Posted")
+ ((equal type 'poll)
+ "Posted a poll")
+ ((equal type 'edit)
+ "Edited"))))
+ id
+ ;; base toot
+ (when (or (equal type 'favourite)
+ (equal type 'boost))
+ status)))))
(defun mastodon-notifications--insert-status
(toot body author-byline action-byline id &optional base-toot)