From a56e2bfcaaa7706a2b27656413170c83bffa6ef0 Mon Sep 17 00:00:00 2001 From: mousebot Date: Fri, 24 Dec 2021 15:10:19 +0100 Subject: refactor mastodon-notifications--insert-status which was a copy of mastodon-tl--insert-status. we revert to having just the latter as main function with optional argument. mastodon-notifications--insert-status just calls it with the arg ID. the reason we need the difference is to ensure notifications have their own ID, and not that of the toot the notif refers to, attached as property "toot-id". then we have all functionality working on notifications, such as boosting mentions and so on. --- lisp/mastodon-tl.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index b2b8026..87b8dfc 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -734,7 +734,7 @@ Runs `mastodon-tl--render-text' and fetches poll or media." (mastodon-tl--get-poll toot)) (mastodon-tl--media toot)))) -(defun mastodon-tl--insert-status (toot body author-byline action-byline) +(defun mastodon-tl--insert-status (toot body author-byline action-byline &optional id) "Display the content and byline of timeline element TOOT. BODY will form the section of the toot above the byline. @@ -744,7 +744,10 @@ portion of the byline that takes one variable. By default it is ACTION-BYLINE is also an optional function for adding an action, such as boosting favouriting and following to the byline. It also takes a single function. By default it is -`mastodon-tl--byline-boosted'" +`mastodon-tl--byline-boosted'. + +ID is that of the toot, which is attached as a property if it is +a notification." (let ((start-pos (point))) (insert (propertize @@ -752,7 +755,8 @@ takes a single function. By default it is body " \n" (mastodon-tl--byline toot author-byline action-byline)) - 'toot-id (alist-get 'id toot) + 'toot-id (or id ; for notifications + (alist-get 'id toot)) 'base-toot-id (mastodon-tl--toot-id toot) 'toot-json toot) "\n") -- cgit v1.2.3 From dd5f445ca7dcdb013c1cb31b61b8ae01444405cc Mon Sep 17 00:00:00 2001 From: mousebot Date: Tue, 11 Jan 2022 18:06:57 +0100 Subject: FIX local mentions/links checking we remove the hacky non-check for a user handle from mastodon-tl--process-link, so that it /always/ runs mastodon-tl--extract-userhandle-from-url. the in extract-userhandle-from-url, we test if the url host = local instance. if so, we just return buffer-text, which = "@user", with no suffix. else we return a full "@user@instance.url" handle. --- lisp/mastodon-tl.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 87b8dfc..0e3de0e 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -494,11 +494,8 @@ START and END are the boundaries of the link in the toot." url toot-instance-url)) (url-instance (concat "https://" (url-host (url-generic-parse-url url)))) - (maybe-userhandle (if (string= mastodon-instance-url url-instance) - ; if handle is local, then no instance suffix: - (buffer-substring-no-properties start end) - (mastodon-tl--extract-userhandle-from-url - url (buffer-substring-no-properties start end))))) + (maybe-userhandle (mastodon-tl--extract-userhandle-from-url + url (buffer-substring-no-properties start end)))) (cond (;; Hashtags: maybe-hashtag (setq mastodon-tab-stop-type 'hashtag @@ -550,11 +547,16 @@ START and END are the boundaries of the link in the toot." BUFFER-TEXT is the text covered by the link with URL, for a user profile this should be of the form , e.g. \"@Gargon\"." - (let ((parsed-url (url-generic-parse-url url))) + (let* ((parsed-url (url-generic-parse-url url)) + (local-p (string= + (url-host (url-generic-parse-url mastodon-instance-url)) + (url-host parsed-url)))) (when (and (string= "@" (substring buffer-text 0 1)) (string= (downcase buffer-text) (downcase (substring (url-filename parsed-url) 1)))) - (concat buffer-text "@" (url-host parsed-url))))) + (if local-p + buffer-text ; no instance suffic for local mention + (concat buffer-text "@" (url-host parsed-url)))))) (defun mastodon-tl--extract-hashtag-from-url (url instance-url) "Return the hashtag that URL points to or nil if URL is not a tag link. -- cgit v1.2.3