From 1cc9cc621c9ab31419f965d5958ff24b1bc8f987 Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 29 Mar 2022 21:34:23 +0200 Subject: toot--reply: improve mentions in replies - make sure we get ID from parent if its a fave/boost - avoid duplicates if user or booster already in mentions list --- lisp/mastodon-toot.el | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 52b061c..79f3d74 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -621,7 +621,8 @@ candidate ARG. IGNORED remains a mystery." (interactive) (let* ((toot (mastodon-tl--property 'toot-json)) (parent (mastodon-tl--property 'parent-toot)) ; for new notifs handling - (id (mastodon-tl--as-string (mastodon-tl--field 'id toot))) + (id (mastodon-tl--as-string + (mastodon-tl--field 'id (or parent toot)))) (account (mastodon-tl--field 'account toot)) (user (alist-get 'acct account)) (mentions (mastodon-toot--mentions (or parent toot))) @@ -634,14 +635,27 @@ candidate ARG. IGNORED remains a mystery." (if (and (not (equal user booster)) (not (string-match booster mentions))) + ;; different booster, user and mentions: (concat (mastodon-toot--process-local user) ;; "@" booster " " - (mastodon-toot--process-local booster) mentions) + (mastodon-toot--process-local booster) + mentions) + ;; booster is either user or in mentions: + (if (not string-match user mentions) + ;; user not already in mentions: + (concat (mastodon-toot--process-local user) + mentions) + ;; user already in mentions: + mentions)) + ;; no booster: + (if (not (string-match user mentions)) + ;; user not in mentions: (concat (mastodon-toot--process-local user) - mentions)) - (concat (mastodon-toot--process-local user) - mentions))) - id (or parent toot)))) + mentions) + ;; user in mentions already: + mentions))) + id + (or parent toot)))) (defun mastodon-toot--toggle-warning () "Toggle `mastodon-toot--content-warning'." -- cgit v1.2.3