aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-auth.el
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-12-16 15:19:49 +0100
committermousebot <mousebot@riseup.net>2021-12-16 15:19:49 +0100
commitd451912722766482371ed491de415f1647cf8b9d (patch)
tree9e4752f2cbd48a216f46a5efb536cbdc55b2fcae /lisp/mastodon-auth.el
parentaf72d4943ad942712ec74a387e79fb1d53e6bee8 (diff)
parenta3dd830e4e7b5eddfc21975506fe5461a36c2a89 (diff)
Merge branch 'develop' into notify-when-post
Diffstat (limited to 'lisp/mastodon-auth.el')
-rw-r--r--lisp/mastodon-auth.el24
1 files changed, 15 insertions, 9 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index 0b0c703..8d0d7c6 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -63,7 +63,10 @@ if you are happy with unencryped storage use e.g. \"~/authinfo\"."
(defun mastodon-auth--generate-token ()
"Make POST to generate auth token.
-If no auth-sources file, runs `mastodon-auth--generate-token-no-storing-credentials'. If auth-sources file exists, runs `mastodon-auth--generate-token-and-store'."
+If no auth-sources file, runs
+`mastodon-auth--generate-token-no-storing-credentials'. If
+auth-sources file exists, runs
+`mastodon-auth--generate-token-and-store'."
(if (or (null mastodon-auth-source-file)
(string= "" mastodon-auth-source-file))
(mastodon-auth--generate-token-no-storing-credentials)
@@ -124,12 +127,15 @@ Reads and/or stores secrets in `MASTODON-AUTH-SOURCE-FILE'."
(json-read-from-string json-string))))
(defun mastodon-auth--access-token ()
- "If an access token for `mastodon-instance-url' is in `mastodon-auth--token-alist', return it.
+ "Return exiting or generate new access token.
-Otherwise, generate a token and pass it to `mastodon-auth--handle-token-reponse'."
+If an access token for `mastodon-instance-url' is in
+`mastodon-auth--token-alist', return it.
+
+Otherwise, generate a token and pass it to
+`mastodon-auth--handle-token-reponse'."
(if-let ((token (cdr (assoc mastodon-instance-url mastodon-auth--token-alist))))
token
-
(mastodon-auth--handle-token-response (mastodon-auth--get-token))))
(defun mastodon-auth--handle-token-response (response)
@@ -151,11 +157,11 @@ Handle any errors from the server."
(defun mastodon-auth--get-account-name ()
"Request user credentials and return an account name."
- (cdr (assoc
- 'acct
- (mastodon-http--get-json
- (mastodon-http--api
- "accounts/verify_credentials")))))
+ (alist-get
+ 'acct
+ (mastodon-http--get-json
+ (mastodon-http--api
+ "accounts/verify_credentials"))))
(defun mastodon-auth--user-acct ()
"Return a mastodon user acct name."