From e4c71fde7c9cdf3a13328edad5eb779396d707ed Mon Sep 17 00:00:00 2001 From: FIGBERT Date: Sat, 24 Jun 2023 12:07:52 +0300 Subject: [PATCH] Add verification to headless log-in flow --- matrix/matrix.go | 11 +++++++++++ ui/view-main.go | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/matrix/matrix.go b/matrix/matrix.go index c18c86c..5ee7924 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -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. @@ -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) } } @@ -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 diff --git a/ui/view-main.go b/ui/view-main.go index 94c6808..e7daa10 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -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