Clean up the URLs a bit

This commit is contained in:
Jakub 2026-05-09 13:02:17 +08:00
parent 65887da8da
commit ab0137230f

View file

@ -43,6 +43,11 @@
:type 'string
:group 'gomuks)
(defcustom gomuks-base-url "localhost:29325"
"The base URL for the Gomuks backend, only IP address and port required."
:type 'string
:group 'gomuks)
(defun gomuks-server-start ()
"Start the gomuks server process"
(interactive)
@ -57,11 +62,10 @@
(kill-process gomuks-server-name)
(notifications-notify :title "Gomuks Server Closed" :app-name "gomuks.el"))
(defvar gomuks-url "http://localhost:29325")
(defvar gomuks-auth-endpoint (concat gomuks-url "/_gomuks/auth"))
(defvar gomuks-auth-cookie )
(defvar gomuks-auth-endpoint (concat "http://" gomuks-base-url "/_gomuks/auth"))
(defvar gomuks-auth-cookie)
(defvar gomuks-ws-endpoint (concat gomuks-url "/_gomuks/websocket"))
(defvar gomuks-ws-endpoint (concat "ws://" gomuks-base-url "/_gomuks/websocket"))
(defun gomuks-connect (gomuks-username)
"Opens a websocket connection with the specified gomuks endpoint"
@ -76,6 +80,7 @@
(base64-encode-string
(concat gomuks-username ":" gomuks-password))))))
(sleep-for 0.5)
;; TODO: this needs to select domain dynamically, instead of hardcoding a string here
(cdar (request--netscape-get-cookies request--curl-cookie-jar "localhost" "/_gomuks" t)))))
(setq gomuks-ping-timer (run-with-timer
0
@ -84,7 +89,7 @@
(message "pinging")
(websocket-send-text gomuks-websocket
"{\"command\":\"ping\"}"))))
(setq gomuks-websocket (websocket-open "ws://localhost:29325/_gomuks/websocket"
(setq gomuks-websocket (websocket-open gomuks-ws-endpoint
:custom-header-alist
`(("Cookie" . ,(concat "gomuks_auth=" gomuks-auth-cookie)))
:on-message (lambda (_ws frame)