diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-02 15:48:03 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-10-02 15:48:56 +0200 |
commit | db053972021aa75b4bc330843445877149d15b61 (patch) | |
tree | 3901427fd6a780d242df7365bbce5a998ebda95e /lisp/mastodon-views.el | |
parent | cada9d84d13e0df5eeafa97f00e34c56a46473b8 (diff) |
add mastodon-views--instance-desc-misskey. TODO merge with other inst funs
partial fix for #468.
Diffstat (limited to 'lisp/mastodon-views.el')
-rw-r--r-- | lisp/mastodon-views.el | 74 |
1 files changed, 58 insertions, 16 deletions
diff --git a/lisp/mastodon-views.el b/lisp/mastodon-views.el index ad36664..5000017 100644 --- a/lisp/mastodon-views.el +++ b/lisp/mastodon-views.el @@ -755,7 +755,44 @@ INSTANCE is an instance domain name." (concat instance "/api/v1/instance") nil nil :vector))) (mastodon-views--instance-response-fun response brief instance))))) -(defun mastodon-views--instance-response-fun (response brief instance) +(defun mastodon-views--instance-desc-misskey (&optional brief instance) + "" + ;; TODO: work out how to try either misskey endpoint or mastodon-compat one. + (interactive) + (mastodon-tl--do-if-toot + (let* ((toot (if (mastodon-tl--profile-buffer-p) + ;; we may be on profile description itself: + (or (mastodon-tl--property 'profile-json) + ;; or on profile account listings, or just toots: + (mastodon-tl--property 'toot-json)) + ;; normal timeline/account listing: + (mastodon-tl--property 'toot-json))) + (reblog (alist-get 'reblog toot)) + (account (or (alist-get 'account reblog) + (alist-get 'account toot) + toot)) ; else `toot' is already an account listing. + ;; we may be at toots/boosts/users in a profile buffer. + ;; profile-json is a defacto test for if point is on the profile + ;; details at the top of a profile buffer. + (profile-note-p (and (mastodon-tl--profile-buffer-p) + ;; only call this in profile buffers: + (mastodon-tl--property 'profile-json))) + (url (if profile-note-p + (alist-get 'url toot) ; profile description + (alist-get 'url account))) + (username (if profile-note-p + (alist-get 'username toot) ;; profile + (alist-get 'username account))) + (instance (mastodon-views--get-instance-url url username instance)) + (params `(("detail" . ,(or brief t)))) + (headers '(("Content-Type" . "application/json"))) + (url (concat instance "/api/meta")) + (response + (with-current-buffer (mastodon-http--post url params headers t :json) + (mastodon-http--process-response)))) + (mastodon-views--instance-response-fun response brief instance :misskey)))) + +(defun mastodon-views--instance-response-fun (response brief instance misskey) "Display instance description RESPONSE in a new buffer. BRIEF means to show fewer details. INSTANCE is the instance were are working with." @@ -764,21 +801,26 @@ INSTANCE is the instance were are working with." (buf (get-buffer-create (format "*mastodon-instance-%s*" domain)))) (with-mastodon-buffer buf #'special-mode :other-window - (when brief - (setq response - (list (assoc 'uri response) - (assoc 'title response) - (assoc 'short_description response) - (assoc 'email response) - (cons 'contact_account - (list - (assoc 'username - (assoc 'contact_account response)))) - (assoc 'rules response) - (assoc 'stats response)))) - (mastodon-views--print-json-keys response) - (mastodon-tl--set-buffer-spec (buffer-name buf) "instance" nil) - (goto-char (point-min)))))) + (if misskey + (let ((inihibit-read-only t)) + (insert (prin1-to-string response)) + (pp-buffer) + (goto-char (point-min))) + (when brief + (setq response + (list (assoc 'uri response) + (assoc 'title response) + (assoc 'short_description response) + (assoc 'email response) + (cons 'contact_account + (list + (assoc 'username + (assoc 'contact_account response)))) + (assoc 'rules response) + (assoc 'stats response)))) + (mastodon-views--print-json-keys response) + (mastodon-tl--set-buffer-spec (buffer-name buf) "instance" nil) + (goto-char (point-min))))))) (defun mastodon-views--format-key (el pad) "Format a key of element EL, a cons, with PAD padding." |