diff options
author | marty hiatt <martianhiatus@disroot.org> | 2024-10-25 20:59:42 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@disroot.org> | 2024-10-25 21:00:01 +0200 |
commit | eb103a8965c367e23f7911ab5e556c0d5e66e5c3 (patch) | |
tree | 8bb971e9049692f59446d07afaef97fe4b56551b /lisp | |
parent | f154ff9ce0e4bb883dbf2925f86a7ba461b861b7 (diff) |
notif-id prop for notifs. get-single-notif cmd. #606
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-notifications.el | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index db78ef7..f688f2d 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -365,6 +365,7 @@ ACCOUNTS is the notification accounts data." 'toot-folded (and toot-foldable (not unfolded)) ;; grouped notifs data: 'notification-type type + 'notification-id (alist-get 'group_key group) 'notification-group group 'notification-accounts accounts ;; for pagination: @@ -486,18 +487,36 @@ Status notifications are created when you call (defun mastodon-notifications--clear-current () "Dismiss the notification at point." (interactive) - (let* ((id (or (mastodon-tl--property 'item-id) - (mastodon-tl--field 'id - (mastodon-tl--property 'item-json)))) - (response - (mastodon-http--post (mastodon-http--api - (format "notifications/%s/dismiss" id))))) + (let* ((id (or (or (mastodon-tl--property 'notification-id) ;; grouped + (mastodon-tl--property 'item-id) + (mastodon-tl--field + 'id + (mastodon-tl--property 'item-json))))) + (endpoint (mastodon-http--api + (format "notifications/%s/dismiss" id) + "v2")) + (response (mastodon-http--post endpoint))) (mastodon-http--triage response (lambda (_) (when mastodon-tl--buffer-spec (mastodon-tl--reload-timeline-or-profile)) (message "Notification dismissed!"))))) +(defun mastodon-notifications--get-single-notif () + "Return a single notification JSON for v2 notifs." + (interactive) + (let* ((id (mastodon-tl--property + 'notification-id)) ;; grouped, doesn't work for ungrouped! + ;; (key (format "ungrouped-%s" + ;; (mastodon-tl--property 'item-id))) + (endpoint (mastodon-http--api + (format "notifications/%s" id) + "v2")) + (response (mastodon-http--get-json endpoint))) + (mastodon-http--triage + response (lambda (_) + (message "%s" (prin1-to-string response)))))) + (defun mastodon-notifications--get-unread-count () "Return the number of unread notifications for the current account." ;; params: limit - max 1000, default 100, types[], exclude_types[], account_id |