From e9d9bc3a6bbe6b54772298e9fc20c2daff963916 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 23 Oct 2024 18:45:43 +0200 Subject: propertize grouped notif authors in help-echo --- lisp/mastodon-notifications.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index b16b5a6..747ab8b 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -385,9 +385,10 @@ When DOMAIN, force inclusion of user's domain in their handle." (propertize ;; help-echo remaining notifs authors: (format " and %s other%s" diff (if (= 1 diff) "" "s")) 'help-echo (mapconcat (lambda (a) - (alist-get 'username a)) + (propertize (alist-get 'username a) + 'face 'mastodon-display-name-face)) (cddr accounts) ;; not first two - " "))))))) + ", "))))))) (defun mastodon-notifications--render (json) "Display grouped notifications in JSON." -- cgit v1.2.3 From f154ff9ce0e4bb883dbf2925f86a7ba461b861b7 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 25 Oct 2024 20:21:19 +0200 Subject: v rough severance/mod warning notifs. WIP. #593 #594 can complete these when we see some in the wild. --- lisp/mastodon-notifications.el | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 747ab8b..db78ef7 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -92,7 +92,8 @@ make them unweildy." (defvar mastodon-notifications--types '("favourite" "reblog" "mention" "poll" - "follow_request" "follow" "status" "update") + "follow_request" "follow" "status" "update" + "severed_relationships" "moderation_warning") "A list of notification types according to their name on the server.") (defvar mastodon-notifications--response-alist @@ -210,6 +211,25 @@ JSON is a list of alists." for x in ids collect (mastodon-notifications--alist-by-value x 'id json))) +(defun mastodon-notifications--severance-body (group) + "Return a body for a severance notification GROUP." + ;; FIXME: actually implement this when we encounter one in the wild! + (let-alist (alist-get 'event group) + (concat .description ": " + .target_name + "\nRelationships affected: " + .relationships_count))) + +(defun mastodon-notifications--mod-warning-body (group) + "Return a body for a moderation warning notification GROUP." + (let-alist (alist-get ) + (concat .description ": " + .text + "\nStatuses: " + .status_ids + "\nfor account: " + .target_account))) + (defun mastodon-notifications--format-note (group status accounts) "Format for a GROUP notification. STATUS is the status's JSON. @@ -258,6 +278,10 @@ ACCOUNTS is data of the accounts that have reacted to the notification." (concat ":\n" (mastodon-notifications--comment-note-text body))))) + ((eq type-sym 'severed_relationships) + (mastodon-notifications--severance-body group)) + ((eq type-sym 'moderation_warning) + (mastodon-notifications--mod-warning-body group)) ((member type-sym '(favourite reblog)) (propertize (mastodon-notifications--comment-note-text body))) -- cgit v1.2.3 From eb103a8965c367e23f7911ab5e556c0d5e66e5c3 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 25 Oct 2024 20:59:42 +0200 Subject: notif-id prop for notifs. get-single-notif cmd. #606 --- lisp/mastodon-notifications.el | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon-notifications.el') 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 -- cgit v1.2.3 From a1d3feea13416a119b6437b5f2bbeba66fb638a1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sun, 27 Oct 2024 16:49:05 +0100 Subject: fix severance/mod warning notifs (experimental still) --- lisp/mastodon-notifications.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index f688f2d..3ef8869 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -215,15 +215,15 @@ JSON is a list of alists." "Return a body for a severance notification GROUP." ;; FIXME: actually implement this when we encounter one in the wild! (let-alist (alist-get 'event group) - (concat .description ": " + (concat .type ": " .target_name "\nRelationships affected: " .relationships_count))) (defun mastodon-notifications--mod-warning-body (group) "Return a body for a moderation warning notification GROUP." - (let-alist (alist-get ) - (concat .description ": " + (let-alist (alist-get 'moderation_warning group) + (concat .action ": " .text "\nStatuses: " .status_ids -- cgit v1.2.3 From eb736070d77d549c97e10f2c3560bcba17ba7d45 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 29 Oct 2024 08:45:33 +0100 Subject: fix timestamp logic in notifs v2 (use base item when necessary) --- lisp/mastodon-notifications.el | 12 ++++++++---- lisp/mastodon-tl.el | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 3ef8869..06bbca7 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -346,10 +346,14 @@ ACCOUNTS is the notification accounts data." 'toot-body t) ;; includes newlines etc. for folding "\n" ;; actual byline: - (mastodon-tl--byline toot author-byline nil nil - base-toot group - (if (member type '("follow" "follow_request")) - toot))) ;; account data! + (mastodon-tl--byline + toot author-byline nil nil base-toot group + (when (member type '("follow" "follow_request")) + toot) ;; account data! + ;; types listed here use base item timestamp, else we use group's + ;; latest timestamp: + (when (not (member type '("favourite" "reblog" "edit" "poll"))) + (mastodon-tl--field 'latest_page_notification_at group)))) 'item-type 'toot ;; for nav, actions, etc. 'item-id (or (alist-get 'page_max_id group) ;; newest notif (alist-get 'id toot)) ; toot id diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 5bd1ec1..5eb52e3 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -797,7 +797,7 @@ LETTER is a string, F for favourited, B for boosted, or K for bookmarked." (image-transforms-p))) (defun mastodon-tl--byline (toot author-byline &optional detailed-p - domain base-toot group account) + domain base-toot group account ts) "Generate byline for TOOT. AUTHOR-BYLINE is a function for adding the author portion of the byline that takes one variable. @@ -809,17 +809,18 @@ this just means displaying toot client. When DOMAIN, force inclusion of user's domain in their handle. BASE-TOOT is JSON for the base toot, if any. GROUP is the notification group if any. -ACCOUNT is the notification account if any." - (let* ((created-time - (if group - (mastodon-tl--field 'latest_page_notification_at group) - ;; bosts and faves in notifs view - ;; (makes timestamps be for the original toot not the boost/fave): - (or (mastodon-tl--field 'created_at - (mastodon-tl--field 'status toot)) - ;; all other toots, inc. boosts/faves in timelines: - ;; (mastodon-tl--field auto fetches from reblogs if needed): - (mastodon-tl--field 'created_at toot)))) +ACCOUNT is the notification account if any. +TS is a timestamp from the server, if any." + (let* ((type (alist-get 'type group)) + (created-time + (or ts ;; mentions, statuses, folls/foll-reqs + ;; bosts, faves, edits, polls in notifs view use base item + ;; timestamp: + (mastodon-tl--field 'created_at + (mastodon-tl--field 'status toot)) + ;; all other toots, inc. boosts/faves in timelines: + ;; (mastodon-tl--field auto fetches from reblogs if needed): + (mastodon-tl--field 'created_at toot))) (parsed-time (when created-time (date-to-time created-time))) (faved (eq t (mastodon-tl--field 'favourited toot))) (boosted (eq t (mastodon-tl--field 'reblogged toot))) -- cgit v1.2.3 From 27e69625d3af99250c8bc943768ab6a770326773 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 29 Oct 2024 10:15:36 +0100 Subject: flychecks --- lisp/mastodon-notifications.el | 1 + lisp/mastodon-transient.el | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index 06bbca7..f4615fb 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -62,6 +62,7 @@ (autoload 'mastodon-media--get-avatar-rendering "mastodon-media") (autoload 'mastodon-tl--image-trans-check "mastodon-tl") (autoload 'mastodon-tl--symbol "mastodon-tl") +(autoload 'mastodon-tl--display-or-uname "mastodon-tl") (defgroup mastodon-tl nil "Nofications in mastodon.el." diff --git a/lisp/mastodon-transient.el b/lisp/mastodon-transient.el index 00d9acf..bbfbfc9 100644 --- a/lisp/mastodon-transient.el +++ b/lisp/mastodon-transient.el @@ -234,7 +234,9 @@ the format fields.X.keyname." (mastodon-toot--fetch-max-poll-option-chars instance))) (transient-define-suffix mastodon-transient--choice-add () - "docstring" + "Add another poll choice if possible. +Do not add more than 9 choices. +Do not add more than the server's maximum setting." (interactive) :transient 'transient--do-stay (let* ((args (transient-args (oref transient-current-prefix command))) -- cgit v1.2.3