aboutsummaryrefslogtreecommitdiff
path: root/modules/slack-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-22 19:32:32 -0500
committerCraig Jennings <c@cjennings.net>2026-05-22 19:32:32 -0500
commitae16048a7d93dd16e78cf059ea7207144eded5a0 (patch)
tree29dc689a85171b920a880578a0650ccc88d1490c /modules/slack-config.el
parent4b296b294f6ddcaefa4b7914a4e36547dfddc3a7 (diff)
downloaddotemacs-ae16048a7d93dd16e78cf059ea7207144eded5a0.tar.gz
dotemacs-ae16048a7d93dd16e78cf059ea7207144eded5a0.zip
refactor(auth): consolidate the auth-source secret lookup into one helper
The auth-source-search + funcall-the-secret block was copied four times: calendar-sync--calendar-url, cj/auth-source-secret (ai-config), cj/--auth-source-password (transcription), and cj/slack--get-credential. Each searched authinfo, pulled :secret, and called it when the netrc backend returned a function. I pulled that into cj/auth-source-secret-value in system-lib (a leaf, so calendar-sync doesn't have to depend on ai-config and drag in the gptel stack). It takes an optional user and returns the secret or nil. The four callers now delegate to it: ai-config layers its required-secret error on top, and the others keep their nil-on-miss behavior. With the direct auth-source-search calls gone, I dropped the now-unused (require 'auth-source) from transcription, slack, and calendar-sync. The helper's autoload covers it. The transcription tests that exercise the delegated path stay green, and the primitive and the error wrapper get their own tests.
Diffstat (limited to 'modules/slack-config.el')
-rw-r--r--modules/slack-config.el11
1 files changed, 2 insertions, 9 deletions
diff --git a/modules/slack-config.el b/modules/slack-config.el
index b51db444..e63b720a 100644
--- a/modules/slack-config.el
+++ b/modules/slack-config.el
@@ -34,7 +34,7 @@
;;; Code:
-(require 'auth-source)
+(require 'system-lib) ;; provides cj/auth-source-secret-value
(require 'cl-lib)
(defvar slack-current-buffer)
@@ -65,14 +65,7 @@
(defun cj/slack--get-credential (login-key)
"Look up LOGIN-KEY credential for the Slack workspace from auth-source."
- (let ((entry (car (auth-source-search :host cj/slack-workspace
- :user login-key
- :max 1))))
- (when entry
- (let ((secret (plist-get entry :secret)))
- (if (functionp secret)
- (funcall secret)
- secret)))))
+ (cj/auth-source-secret-value cj/slack-workspace login-key))
(defun cj/slack-start ()
"Connect to Slack, registering the team if needed."