Adds account switching

This commit is contained in:
2026-06-10 12:12:31 -04:00
parent 8d820432ff
commit 02d78765bc
8 changed files with 330 additions and 2 deletions
+32
View File
@@ -13,6 +13,7 @@
(require 'noise-rpc)
(require 'noise-chat-list)
(require 'noise-new-chat)
(defgroup noise nil
"Signal Messenger client for Emacs."
@@ -26,6 +27,37 @@ The default port is 8080, matching signal-cli's `--http` default."
:type 'string
:group 'noise)
(defcustom noise-account nil
"The Signal account to use, as a phone number in E.164 format.
signal-cli can have multiple accounts registered. When the daemon
serves more than one account, every request must say which account it
is for, so this must be set (e.g. \"+15551234567\"). When nil, the
daemon is assumed to serve a single account (started with `-a`).
Use `noise-select-account' to pick one interactively from the
accounts registered with signal-cli."
:type '(choice (const :tag "Single-account daemon" nil)
(string :tag "Phone number (E.164)"))
:group 'noise)
;;;###autoload
(defun noise-select-account ()
"Select which signal-cli account Noise should use.
Queries the daemon for registered accounts and sets `noise-account'."
(interactive)
(let* ((accounts (noise-rpc-call "listAccounts"))
(numbers (mapcar (lambda (a) (gethash "number" a))
(append accounts nil))))
(cond
((null numbers)
(user-error "No accounts registered with signal-cli"))
((null (cdr numbers))
(setq noise-account (car numbers)))
(t
(setq noise-account
(completing-read "Signal account: " numbers nil t))))
(message "Using Signal account %s" noise-account)))
;;;###autoload
(defun noise-check-connection ()
"Check connectivity to the signal-cli JSON-RPC daemon."