diff options
author | Abhiseck Paira <abhiseckpaira@disroot.org> | 2022-01-17 20:23:22 +0530 |
---|---|---|
committer | Abhiseck Paira <abhiseckpaira@disroot.org> | 2022-01-17 20:23:22 +0530 |
commit | 639f89eb714efea5062bdbf21995033f57ea5207 (patch) | |
tree | 3718007316335f86efcf43d353605062a5edd756 /lisp/mastodon-client.el | |
parent | 6305a5b809fc9185626c2cbcdf43ba4416efeb11 (diff) |
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'.
Diffstat (limited to 'lisp/mastodon-client.el')
-rw-r--r-- | lisp/mastodon-client.el | 17 |
1 files changed, 17 insertions, 0 deletions
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'. |