From 639f89eb714efea5062bdbf21995033f57ea5207 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Mon, 17 Jan 2022 20:23:22 +0530 Subject: make a public interface for accessing user details Introduce the function `mastodon-client-active-user' for public use which returns the details of the currently active users. It performs similar function as that of the function `mastodon-client'. --- lisp/mastodon-client.el | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lisp/mastodon-client.el') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index d622e52..e0ae34c 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -46,6 +46,9 @@ (defvar mastodon-client--client-details-alist nil "An alist of Client id and secrets keyed by the instance url.") +(defvar mastodon-client--active-user-details-plist nil + "A plist of active user details.") + (defvar mastodon-client-scopes "read write follow" "Scopes to pass to oauth during registration.") @@ -174,6 +177,20 @@ Otherwise return nil." (when (and user-details (equal (plist-get user-details :username) username)) user-details))) + +(defun mastodon-client-active-user () + "Return the details of the currently active user. + +Details is a plist." + (let ((active-user-details mastodon-client--active-user-details-plist)) + (unless active-user-details + (setq active-user-details + (or (mastodon-client--current-user-active-p) + (mastodon-client--make-current-user-active))) + (setq mastodon-client--active-user-details-plist + active-user-details)) + active-user-details)) + (defun mastodon-client () "Return variable client secrets to use for `mastodon-instance-url'. -- cgit v1.2.3