1
0
Fork 0
forked from Mirrors/gomuks

Configure MxID and homeserver in headless startup

This commit is contained in:
FIGBERT 2023-08-08 16:56:57 -07:00
parent 5db39fd50a
commit c628bfb97c
No known key found for this signature in database
GPG key ID: 67F1598D607A844B

View file

@ -9,6 +9,7 @@ import (
"maunium.net/go/mautrix" "maunium.net/go/mautrix"
"maunium.net/go/mautrix/crypto" "maunium.net/go/mautrix/crypto"
"maunium.net/go/mautrix/crypto/ssss" "maunium.net/go/mautrix/crypto/ssss"
"maunium.net/go/mautrix/id"
"maunium.net/go/gomuks/initialize" "maunium.net/go/gomuks/initialize"
"maunium.net/go/gomuks/matrix" "maunium.net/go/gomuks/matrix"
@ -16,10 +17,8 @@ import (
) )
type HeadlessConfig struct { type HeadlessConfig struct {
OutputDir, OutputDir, MxPassword, KeyPath, KeyPassword, RecoveryPhrase string
MxID, MxPassword, MxID id.UserID
KeyPath, KeyPassword,
RecoveryPhrase string
} }
func HeadlessInit(conf HeadlessConfig) error { func HeadlessInit(conf HeadlessConfig) error {
@ -39,9 +38,15 @@ func HeadlessInit(conf HeadlessConfig) error {
} }
// login section // login section
_, hs, err := conf.MxID.Parse()
if err != nil {
return err
}
gmx.Config().HS = hs
if err := gmx.Matrix().InitClient(false); err != nil { if err := gmx.Matrix().InitClient(false); err != nil {
return err return err
} else if err = gmx.Matrix().Login(conf.MxID, conf.MxPassword); err != nil { } else if err = gmx.Matrix().Login(conf.MxID.String(), conf.MxPassword); err != nil {
return err return err
} }