Skip to content

Commit

Permalink
Add verification to headless log-in flow
Browse files Browse the repository at this point in the history
  • Loading branch information
FIGBERT committed Jun 24, 2023
1 parent 8ed5a4b commit e4c71fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"maunium.net/go/gomuks/lib/open"
"maunium.net/go/gomuks/matrix/muksevt"
"maunium.net/go/gomuks/matrix/rooms"
"maunium.net/go/gomuks/ui"
)

// Container is a wrapper for a mautrix Client and some other stuff.
Expand Down Expand Up @@ -433,6 +434,8 @@ func (c *Container) OnLogin() {
c.syncer.Progress = StubSyncingModal{}
c.syncer.FirstDoneCallback = nil
if c.headless {
c.RunCommand("/cs fetch")
c.RunCommand("/cs self-sign")
c.gmx.Stop(true)
}
}
Expand Down Expand Up @@ -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) {
if source&mautrix.EventSourceAccountData == 0 {
return
Expand Down
4 changes: 4 additions & 0 deletions ui/view-main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func (ui *GomuksUI) NewMainView() mauview.Component {
return mainView
}

func (view *MainView) CmdProcessor() *CommandProcessor {
return view.cmdProcessor
}

func (view *MainView) ShowModal(modal mauview.Component) {
view.modal = modal
var ok bool
Expand Down

0 comments on commit e4c71fd

Please sign in to comment.