1
0
Fork 0
forked from Mirrors/gomuks

Add verification to headless log-in flow

This commit is contained in:
FIGBERT 2023-06-24 12:07:52 +03:00
parent 8ed5a4b1dd
commit e4c71fde7c
No known key found for this signature in database
GPG key ID: 67F1598D607A844B
2 changed files with 15 additions and 0 deletions

View file

@ -47,6 +47,7 @@ import (
"maunium.net/go/gomuks/lib/open" "maunium.net/go/gomuks/lib/open"
"maunium.net/go/gomuks/matrix/muksevt" "maunium.net/go/gomuks/matrix/muksevt"
"maunium.net/go/gomuks/matrix/rooms" "maunium.net/go/gomuks/matrix/rooms"
"maunium.net/go/gomuks/ui"
) )
// Container is a wrapper for a mautrix Client and some other stuff. // Container is a wrapper for a mautrix Client and some other stuff.
@ -433,6 +434,8 @@ func (c *Container) OnLogin() {
c.syncer.Progress = StubSyncingModal{} c.syncer.Progress = StubSyncingModal{}
c.syncer.FirstDoneCallback = nil c.syncer.FirstDoneCallback = nil
if c.headless { if c.headless {
c.RunCommand("/cs fetch")
c.RunCommand("/cs self-sign")
c.gmx.Stop(true) c.gmx.Stop(true)
} }
} }
@ -504,6 +507,14 @@ func (c *Container) Start() {
} }
} }
func (c *Container) RunCommand(text string) {
if view, ok := c.ui.MainView().(*ui.MainView); ok {
if cmd := view.CmdProcessor().ParseCommand(nil, text); cmd != nil {
view.CmdProcessor().HandleCommand(cmd)
}
}
}
func (c *Container) HandlePreferences(source mautrix.EventSource, evt *event.Event) { func (c *Container) HandlePreferences(source mautrix.EventSource, evt *event.Event) {
if source&mautrix.EventSourceAccountData == 0 { if source&mautrix.EventSourceAccountData == 0 {
return return

View file

@ -88,6 +88,10 @@ func (ui *GomuksUI) NewMainView() mauview.Component {
return mainView return mainView
} }
func (view *MainView) CmdProcessor() *CommandProcessor {
return view.cmdProcessor
}
func (view *MainView) ShowModal(modal mauview.Component) { func (view *MainView) ShowModal(modal mauview.Component) {
view.modal = modal view.modal = modal
var ok bool var ok bool