aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-12 14:57:22 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-12 18:11:48 -0400
commit993dfce9bda9a8562b37dee08a7918e0acfaef78 (patch)
tree065033436dc5377d39f56bbdffa4462572057f44 /lisp
parentb719e9054f902e3b4339e35bf85e2141c49248ed (diff)
Refactor mastodon--register-and-return-client-app
Add and use `mastodon-auth--client-app-secret-p'
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-auth.el13
1 files changed, 10 insertions, 3 deletions
diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el
index 0814024..260f838 100644
--- a/lisp/mastodon-auth.el
+++ b/lisp/mastodon-auth.el
@@ -67,11 +67,18 @@ STATUS is passed by `url-retrieve'."
("scopes" . "read write follow")
("website" . "https://github.com/jdenen/mastodon.el"))))
+(defun mastodon-auth--client-app-secret-p ()
+ "Return t if `mastodon--client-app-plist' has a :client_secret value."
+ (when (plist-get mastodon--client-app-plist :client_secret) t))
+
(defun mastodon--register-and-return-client-app ()
"Register `mastodon' with an instance. Return `mastodon--client-app-plist'."
- (progn
- (mastodon--register-client-app)
- mastodon--client-app-plist))
+ (if (mastodon-auth--client-app-secret-p)
+ mastodon--client-app-plist
+ (progn
+ (mastodon--register-client-app)
+ (sleep-for 2)
+ (mastodon--register-and-return-client-app))))
(defun mastodon--store-client-id-and-secret ()
"Store `:client_id' and `:client_secret' in a plstore."