branch: elpa/mastodon
commit 31a9fc88f249fcbd5f35d5006e357b44596492f6
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    Nodeinfo command parse data. #723.
---
 lisp/mastodon-tl.el | 39 +++++++++++++++++----------------------
 lisp/mastodon.el    |  1 +
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 553e98dab1..da2a9122d3 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -3828,28 +3828,23 @@ https://nodeinfo.diaspora.software.";
          (url (mastodon-tl--field 'url item))
          (instance (url-host (url-generic-parse-url url)))
          (data (mastodon-tl--get-nodeinfo instance)))
-    ;; FIXME: parse some data!:
-    ;; e.g. data (sharkey or poss pleroma has much more):
-    ;; ((version . "2.0") ;; nodeinfo iself
-    ;;  (software
-    ;;   (name . "mastodon") ;; important
-    ;;   (version . "4.4.0-nightly.2025-06-21")) ;; important
-    ;;  (protocols "activitypub")
-    ;;  (services
-    ;;   (outbound)
-    ;;   (inbound))
-    ;;  (usage ;; meh
-    ;;   (users
-    ;;    (total . 2778491)
-    ;;    (activeMonth . 284973)
-    ;;    (activeHalfyear . 766793))
-    ;;   (localPosts . 135874775))
-    ;;  (openRegistrations . t) ;; handy
-    ;;  (metadata
-    ;;   (nodeName . "Mastodon")
-    ;;   (nodeDescription . "The original server operated by the Mastodon\
-    ;;   gGmbH non-profit"))) ;; instance description
-    (message "%s" data)))
+    (when data ;; don't display empty message when fetching failed
+      (if (eq 'error (caar data))
+          (user-error "Error: %s" (alist-get 'error data))
+        (mastodon-tl--render-nodeinfo data)))))
+
+(defun mastodon-tl--render-nodeinfo (data)
+  "Render Nodeinfo DADA as message."
+  (let-alist data
+    (message
+     "%s"
+     (concat "Software: "
+             .software.name " " .software.version
+             (if (not .metadata)
+                 ""
+               (concat
+                "\nInstance: "
+                .metadata.nodeName " " .metadata.nodeDescription))))))
 
 ;;; BOOKMARKS
 
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 185a85edd9..980a96e5fe 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -267,6 +267,7 @@ Also nil `mastodon-auth--token-alist'."
     (define-key map (kbd ",")      #'mastodon-toot-list-favouriters)
     (define-key map (kbd ".")      #'mastodon-toot-list-boosters)
     (define-key map (kbd ";")      #'mastodon-views-view-instance-description)
+    (define-key map (kbd "M-;")    #'mastodon-tl-nodeinfo-for-toot)
     ;; override special mode binding
     (define-key map (kbd "g")      #'undefined)
     (define-key map (kbd "g")      #'mastodon-tl-update)

Reply via email to