From 03365c8fbaac2c71e6bbfed731ae88d551175c2c Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Tue, 28 Dec 2021 14:58:44 +0530 Subject: abstract Mastodon API request info Mastodon API requires some info that needs to be passed during app registration and user authentication. Those info were hard coded into various functions. Introduce three variables (defvars): 1. mastodon-client-scopes 2. mastodon-client-website 3. mastodon-client-redirect-uri use them to abstract those info. Also refactor `mastodon-client--register' function in terms of these variables. --- lisp/mastodon-client.el | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index b27d434..9fb45f7 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -46,14 +46,23 @@ (defvar mastodon-client--client-details-alist nil "An alist of Client id and secrets keyed by the instance url.") +(defvar mastodon-client-scopes "read write follow" + "Scopes to pass to oauth during registration.") + +(defvar mastodon-client-website "https://codeberg.org/martianh/mastodon.el" + "Website of mastodon.el.") + +(defvar mastodon-client-redirect-uri "urn:ietf:wg:oauth:2.0:oob" + "Redirect_uri as required by oauth.") + (defun mastodon-client--register () "POST client to Mastodon." (mastodon-http--post (mastodon-http--api "apps") - '(("client_name" . "mastodon.el") - ("redirect_uris" . "urn:ietf:wg:oauth:2.0:oob") - ("scopes" . "read write follow") - ("website" . "https://github.com/jdenen/mastodon.el")) + `(("client_name" . "mastodon.el") + ("redirect_uris" . ,mastodon-client-redirect-uri) + ("scopes" . ,mastodon-client-scopes) + ("website" . ,mastodon-client-website)) nil :unauthenticated)) -- cgit v1.2.3