From 32225214c8de7d659af07eba4250fed96c6af852 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 9 May 2023 19:21:32 +0200 Subject: let-alist follow-request-process --- lisp/mastodon-notifications.el | 45 +++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index bed2d9a..b402f2a 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -108,31 +108,26 @@ follow-requests view." (plist-get mastodon-tl--buffer-spec 'endpoint))) (f-req-p (or (string= "follow_request" (alist-get 'type toot-json)) ;notifs f-reqs-view-p))) - (if f-req-p - (let* ((account (or (alist-get 'account toot-json) ;notifs - toot-json)) ;f-reqs - (id (alist-get 'id account)) - (handle (alist-get 'acct account)) - (name (alist-get 'username account))) - (if id - (let ((response - (mastodon-http--post - (concat - (mastodon-http--api "follow_requests") - (format "/%s/%s" id (if reject - "reject" - "authorize")))))) - (mastodon-http--triage response - (lambda () - (if f-reqs-view-p - (mastodon-views--view-follow-requests) - (mastodon-tl--reload-timeline-or-profile)) - (message "Follow request of %s (@%s) %s!" - name handle (if reject - "rejected" - "accepted"))))) - (message "No account result at point?"))) - (message "No follow request at point?"))))) + (if (not f-req-p) + (message "No follow request at point?") + (let-alist (or (alist-get 'account toot-json) ;notifs + toot-json) ;f-reqs + (if .id + (let ((response + (mastodon-http--post + (concat + (mastodon-http--api "follow_requests") + (format "/%s/%s" .id (if reject "reject" "authorize")))))) + (mastodon-http--triage response + (lambda () + (if f-reqs-view-p + (mastodon-views--view-follow-requests) + (mastodon-tl--reload-timeline-or-profile)) + (message "Follow request of %s (@%s) %s!" + .username .acct (if reject + "rejected" + "accepted"))))) + (message "No account result at point?"))))))) (defun mastodon-notifications--follow-request-accept () "Accept a follow request. -- cgit v1.2.3 From 45b5d3f460e6c5578b35eee4ed5a904b8fbeae91 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Tue, 9 May 2023 19:32:29 +0200 Subject: audit notifications.el --- lisp/mastodon-notifications.el | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'lisp/mastodon-notifications.el') diff --git a/lisp/mastodon-notifications.el b/lisp/mastodon-notifications.el index b402f2a..df96122 100644 --- a/lisp/mastodon-notifications.el +++ b/lisp/mastodon-notifications.el @@ -80,8 +80,7 @@ "Alist of subjects for notification types.") (defvar mastodon-notifications--map - (let ((map - (copy-keymap mastodon-mode-map))) + (let ((map (copy-keymap mastodon-mode-map))) (define-key map (kbd "a") #'mastodon-notifications--follow-request-accept) (define-key map (kbd "j") #'mastodon-notifications--follow-request-reject) (define-key map (kbd "C-k") #'mastodon-notifications--clear-current) @@ -90,11 +89,8 @@ (defun mastodon-notifications--byline-concat (message) "Add byline for TOOT with MESSAGE." - (concat - " " - (propertize message 'face 'highlight) - " " - (cdr (assoc message mastodon-notifications--response-alist)))) + (concat " " (propertize message 'face 'highlight) + " " (cdr (assoc message mastodon-notifications--response-alist)))) (defun mastodon-notifications--follow-request-process (&optional reject) "Process the follow request at point. @@ -181,6 +177,7 @@ Status notifications are given when (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 @@ -193,6 +190,7 @@ Status notifications are given when note) (t status)) + ;; body (if (or (equal type 'follow) (equal type 'follow-request)) (propertize (if (equal type 'follow) @@ -204,13 +202,14 @@ Status notifications are given when (if (mastodon-tl--has-spoiler status) (mastodon-tl--spoiler status) (mastodon-tl--content status)))) + ;; author-byline (if (or (equal type 'follow) (equal type 'follow-request) (equal type 'mention)) 'mastodon-tl--byline-author (lambda (_status) - (mastodon-tl--byline-author - note))) + (mastodon-tl--byline-author note))) + ;; action-byline (lambda (_status) (mastodon-notifications--byline-concat (cond ((equal type 'boost) @@ -230,13 +229,13 @@ Status notifications are given when ((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) +(defun mastodon-notifications--insert-status + (toot body author-byline action-byline id &optional base-toot) "Display the content and byline of timeline element TOOT. BODY will form the section of the toot above the byline. @@ -301,8 +300,7 @@ Status notifications are created when you call (defun mastodon-notifications--filter-types-list (type) "Return a list of notification types with TYPE removed." - (let ((types - (mapcar #'car mastodon-notifications--types-alist))) + (let ((types (mapcar #'car mastodon-notifications--types-alist))) (remove type types))) (defun mastodon-notifications--clear-all () -- cgit v1.2.3