aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorAbhiseck Paira <abhiseckpaira@disroot.org>2022-01-17 19:55:33 +0530
committerAbhiseck Paira <abhiseckpaira@disroot.org>2022-01-17 19:55:33 +0530
commita80bd14c4c22bf5aeda7b37e6f0631a9f4912384 (patch)
tree6029f483a1208c01c6d420ac9de542ad96850133 /lisp
parent8e36abecbb8fa0df1aba30b1100130e5e382b92b (diff)
get account ID from user variables specified in the init file
Get user account ID from the mastodon variables specified in the init file by introducing the function `mastodon-client-form-user-from-vars'. Return user account ID in the form "user@instance.com" when the values of `mastodon-active-user' and `mastodon-instance-url' are "user" and "https://instance.com" respectively.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-client.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el
index 7a857a2..f7d06a5 100644
--- a/lisp/mastodon-client.el
+++ b/lisp/mastodon-client.el
@@ -116,6 +116,15 @@ Return plist without the KEY."
(plstore-item (plstore-get plstore key)))
(mastodon-client--remove-key-from-plstore plstore-item)))
+(defun mastodon-client-form-user-from-vars ()
+ "Create a username from user variable. Return that username.
+
+Username in the form user@instance.com is formed from the
+variables `mastodon-instance-url' and `mastodon-active-user'."
+ (concat mastodon-active-user
+ "@"
+ (url-host (url-generic-parse-url mastodon-instance-url))))
+
(defun mastodon-client ()
"Return variable client secrets to use for `mastodon-instance-url'.