From 993dfce9bda9a8562b37dee08a7918e0acfaef78 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Wed, 12 Apr 2017 14:57:22 -0400 Subject: Refactor mastodon--register-and-return-client-app Add and use `mastodon-auth--client-app-secret-p' --- lisp/mastodon-auth.el | 13 ++++++++++--- 1 file 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." -- cgit v1.2.3