aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-17 11:08:24 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-17 12:01:18 +0100
commit0bd8213302e4cbeb8483a2bef47f09cf2d8e9da2 (patch)
treec66c9da877e9fad825570197c0548f98688b22ac /lisp
parentf03f26e953bfd521432efdd62c565755d90991cc (diff)
add notifications--get-mentions
fix endpoint arg in init-sync
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-notifications.el19
-rw-r--r--lisp/mastodon-tl.el15
-rw-r--r--lisp/mastodon.el1
3 files changed, 30 insertions, 5 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el
index 45bd222..27b01c1 100644
--- a/lisp/mastodon-notifications.el
+++ b/lisp/mastodon-notifications.el
@@ -268,16 +268,29 @@ of the toot responded to."
(mapc #'mastodon-notifications--by-type json)
(goto-char (point-min))))
-(defun mastodon-notifications--get ()
- "Display NOTIFICATIONS in buffer."
+(defun mastodon-notifications--get (&optional type)
+ "Display NOTIFICATIONS in buffer.
+Optionally only print notifications of type TYPE, a string."
(interactive)
(message "Loading your notifications...")
(mastodon-tl--init-sync
"notifications"
"notifications"
- 'mastodon-notifications--timeline)
+ 'mastodon-notifications--timeline
+ type)
(use-local-map mastodon-notifications--map))
+(defun mastodon-notifications--get-mentions ()
+ "Display mention notifications in buffer."
+ (interactive)
+ (mastodon-notifications--get "mention"))
+
+(defun mastodon-notifications--filter-types-list (type)
+ "Return a list of notification types with TYPE (and \"status\") removed."
+ (let ((types (remove "status"
+ (mapcar #'car mastodon-notifications--types-alist))))
+ (remove type types)))
+
(defun mastodon-notifications--clear-all ()
"Clear all notifications."
(interactive)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index f0ef000..8c02adf 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2103,12 +2103,23 @@ headers."
;; for everything save profiles
(mastodon-tl--goto-first-item)))))
-(defun mastodon-tl--init-sync (buffer-name endpoint update-function)
+(defun mastodon-tl--init-sync (buffer-name endpoint update-function &optional note-type)
"Initialize BUFFER-NAME with timeline targeted by ENDPOINT.
UPDATE-FUNCTION is used to receive more toots.
Runs synchronously."
- (let* ((url (mastodon-http--api endpoint))
+ (let* ((exclude-types (when note-type
+ (mastodon-notifications--filter-types-list note-type)))
+ (args (when note-type
+ (mapcar (lambda (x)
+ `("exclude_types[]" . ,x))
+ exclude-types)))
+ (query-string (when note-type
+ (mastodon-http--build-query-string args)))
+ ;; add note-type exclusions to endpoint so it works in `mastodon-tl--buffer-spec'
+ ;; that way `mastodon-tl--more' works seamlessly too:
+ (endpoint (if note-type (concat endpoint "?" query-string) endpoint))
+ (url (mastodon-http--api endpoint))
(buffer (concat "*mastodon-" buffer-name "*"))
(json (mastodon-http--get-json url)))
(with-output-to-temp-buffer buffer
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 1aec556..707ce82 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -193,6 +193,7 @@ Use. e.g. \"%c\" for your locale's date and time format."
(define-key map (kbd "K") #'mastodon-profile--view-bookmarks)
(define-key map (kbd "I") #'mastodon-tl--view-filters)
(define-key map (kbd "G") #'mastodon-tl--get-follow-suggestions)
+ (define-key map (kbd "@") #'mastodon-notifications--get-mentions)
(when (require 'lingva nil :no-error)
(define-key map (kbd "s") #'mastodon-toot--translate-toot-text))
map)