From 20db4e11f54e324af9e7e6c8f96a75589445629b Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Thu, 13 Jan 2022 16:03:11 +0530 Subject: mastodon.el: introduce new defcustom `mastodon-active-user' Use `mastodon-active-user' and `mastodon-instance-url' to determine which mastodon account the user wants to be active for the current session of Emacs. See the documentation string of this variable for details on how to use it. This new variable becomes necessary to prevent conflict when a user has two accounts on the same instance, that is same value of `mastodon-instance-url'. --- lisp/mastodon.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index f65a86d..c7fcccf 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -95,6 +95,19 @@ (defcustom mastodon-instance-url "https://mastodon.social" "Base URL for the Masto instance from which you toot." +(defcustom mastodon-active-user "user" + "Username of the active user. + +For example, if your mastodon username is +\"example_user@social.instance.org\", and you want this account +to be active, the value of this variable should be +\"example_user\". + +Also for completeness, the value of `mastodon-instance-url' +should be \"https://social.instance.org\". + +After setting these variables you should restart Emacs for these +changes to take effect." :group 'mastodon :type 'string) -- cgit v1.2.3 From 2349750b607388a1a665c5e68b5708d9563ecaff Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Thu, 13 Jan 2022 16:22:10 +0530 Subject: mastodon.el: update `mastodon-instance-url' docstring Update the docstring for the defcustom `mastodon-instance-url' to clarify what it's value should be to reflect the changes introduced in the previous commit. --- lisp/mastodon.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index c7fcccf..2758f9d 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -94,7 +94,21 @@ :group 'external) (defcustom mastodon-instance-url "https://mastodon.social" - "Base URL for the Masto instance from which you toot." + "Base URL for the Mastodon instance you want to be active. + +For example, if your mastodon username is +\"example_user@social.instance.org\", and you want this account +to be active, the value of this variable should be +\"https://social.instance.org\". + +Also for completeness, the value of `mastodon-active-user' should +be \"example_user\". + +After setting these variables you should restart Emacs for these +changes to take effect." + :group 'mastodon + :type 'string) + (defcustom mastodon-active-user "user" "Username of the active user. -- cgit v1.2.3 From f037340225fecb16ed7bb92c26a56e0a96c8aee6 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Tue, 28 Dec 2021 19:29:40 +0530 Subject: update copyright holder info Update Copyright holder info for files that have undergone non trivial changes. --- lisp/mastodon-auth.el | 1 + lisp/mastodon-client.el | 1 + lisp/mastodon.el | 1 + 3 files changed, 3 insertions(+) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 72c0333..c09dfdf 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -1,6 +1,7 @@ ;;; mastodon-auth.el --- Auth functions for mastodon.el -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 diff --git a/lisp/mastodon-client.el b/lisp/mastodon-client.el index 13e0150..c577fec 100644 --- a/lisp/mastodon-client.el +++ b/lisp/mastodon-client.el @@ -1,6 +1,7 @@ ;;; mastodon-client.el --- Client functions for mastodon.el -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 2758f9d..d22c842 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -1,6 +1,7 @@ ;;; mastodon.el --- Client for Mastodon -*- lexical-binding: t -*- ;; Copyright (C) 2017-2019 Johnson Denen +;; Copyright (C) 2021 Abhiseck Paira ;; Author: Johnson Denen ;; Maintainer: Marty Hiatt ;; Version: 0.10.0 -- cgit v1.2.3 From 6ac09ec8bc5f3011e59602b030d45ce3f3860e25 Mon Sep 17 00:00:00 2001 From: Abhiseck Paira Date: Fri, 25 Feb 2022 19:43:08 +0530 Subject: auth: make old mastodon.el users aware Most old users of the mastodon.el wouldn't know about the introduction of new variable `mastodon-active-user'[1]. Our goal is to make them aware. Set the default value of [1] to nil. This way we can know that the user hasn't set [1] properly because user is unaware of it. In the definition of `mastodon-auth--access-token', check [1]'s value and if it's null, explain to the user about the new situation. Finally signal the error "Variables not set properly". We have considered the possibility of automating the process but since the new login mechanism depends on setting [1] *in the init file*, the only way to automate it would be to write to user's init file which we consider to be very rude and shouldn't be done by this package. --- lisp/mastodon-auth.el | 8 ++++++++ lisp/mastodon.el | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon.el') diff --git a/lisp/mastodon-auth.el b/lisp/mastodon-auth.el index 491d6ae..bad9e08 100644 --- a/lisp/mastodon-auth.el +++ b/lisp/mastodon-auth.el @@ -48,6 +48,7 @@ (defvar mastodon-instance-url) (defvar mastodon-client-scopes) (defvar mastodon-client-redirect-uri) +(defvar mastodon-active-user) (defgroup mastodon-auth nil "Authenticate with Mastodon." @@ -172,6 +173,13 @@ Generate/save token if none known yet." mastodon-auth--token-alist) (alist-get mastodon-instance-url mastodon-auth--token-alist nil nil 'equal)) + ((null mastodon-active-user) + ;; user not aware of 2FA related changes and has not set the + ;; `mastodon-active-user' properly. Make user aware and error + ;; out. + (mastodon-auth--show-notice mastodon-auth--user-unaware + "*mastodon-notice*") + (error "Variables not set properly")) (t ;; user access-token needs to fetched from the server and ;; stored and variables initialised. diff --git a/lisp/mastodon.el b/lisp/mastodon.el index d22c842..6daa755 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -110,7 +110,7 @@ changes to take effect." :group 'mastodon :type 'string) -(defcustom mastodon-active-user "user" +(defcustom mastodon-active-user nil "Username of the active user. For example, if your mastodon username is -- cgit v1.2.3