mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
Move sync before verification in headless mode
This commit is contained in:
parent
f6f1a906d0
commit
fb10f59801
2 changed files with 42 additions and 35 deletions
|
@ -63,29 +63,6 @@ func Init(conf Config, updates chan fmt.Stringer) error {
|
||||||
}
|
}
|
||||||
updates <- importedKeys{imported: imported, total: total}
|
updates <- importedKeys{imported: imported, total: total}
|
||||||
|
|
||||||
// verify (fetch)
|
|
||||||
key, err := getSSSS(mach, conf.RecoveryPhrase)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = mach.FetchCrossSigningKeysFromSSSS(key)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Error fetching cross-signing keys: %v", err)
|
|
||||||
}
|
|
||||||
updates <- fetchedVerificationKeys{}
|
|
||||||
|
|
||||||
// verify (sign)
|
|
||||||
if mach.CrossSigningKeys == nil {
|
|
||||||
return fmt.Errorf("Cross-signing keys not cached")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = mach.SignOwnDevice(mach.OwnIdentity())
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("Failed to self-sign: %v", err)
|
|
||||||
}
|
|
||||||
updates <- successfullyVerified{}
|
|
||||||
|
|
||||||
// display mode
|
// display mode
|
||||||
gmx.Config().Preferences.DisplayMode = config.DisplayModeModern
|
gmx.Config().Preferences.DisplayMode = config.DisplayModeModern
|
||||||
updates <- configuredDisplayMode{}
|
updates <- configuredDisplayMode{}
|
||||||
|
@ -109,6 +86,30 @@ func Init(conf Config, updates chan fmt.Stringer) error {
|
||||||
gmx.Matrix().(*matrix.Container).InitSyncer()
|
gmx.Matrix().(*matrix.Container).InitSyncer()
|
||||||
updates <- processingSync{}
|
updates <- processingSync{}
|
||||||
err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "")
|
err = gmx.Matrix().(*matrix.Container).ProcessSyncResponse(resp, "")
|
||||||
|
updates <- syncFinished{}
|
||||||
|
|
||||||
|
// verify (fetch)
|
||||||
|
key, err := getSSSS(mach, conf.RecoveryPhrase)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = mach.FetchCrossSigningKeysFromSSSS(key)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Error fetching cross-signing keys: %v", err)
|
||||||
|
}
|
||||||
|
updates <- fetchedVerificationKeys{}
|
||||||
|
|
||||||
|
// verify (sign)
|
||||||
|
if mach.CrossSigningKeys == nil {
|
||||||
|
return fmt.Errorf("Cross-signing keys not cached")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = mach.SignOwnDevice(mach.OwnIdentity())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("Failed to self-sign: %v", err)
|
||||||
|
}
|
||||||
|
updates <- successfullyVerified{}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,18 +26,6 @@ func (msg importedKeys) String() string {
|
||||||
return fmt.Sprintf("Successfully imported %d/%d sessions", msg.imported, msg.total)
|
return fmt.Sprintf("Successfully imported %d/%d sessions", msg.imported, msg.total)
|
||||||
}
|
}
|
||||||
|
|
||||||
type fetchedVerificationKeys struct{}
|
|
||||||
|
|
||||||
func (msg fetchedVerificationKeys) String() string {
|
|
||||||
return "Successfully unlocked cross-signing keys…"
|
|
||||||
}
|
|
||||||
|
|
||||||
type successfullyVerified struct{}
|
|
||||||
|
|
||||||
func (msg successfullyVerified) String() string {
|
|
||||||
return "Successfully self-signed. This device is now trusted by other devices…"
|
|
||||||
}
|
|
||||||
|
|
||||||
type configuredDisplayMode struct{}
|
type configuredDisplayMode struct{}
|
||||||
|
|
||||||
func (msg configuredDisplayMode) String() string {
|
func (msg configuredDisplayMode) String() string {
|
||||||
|
@ -61,3 +49,21 @@ type processingSync struct{}
|
||||||
func (msg processingSync) String() string {
|
func (msg processingSync) String() string {
|
||||||
return "Processing sync response…"
|
return "Processing sync response…"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type syncFinished struct{}
|
||||||
|
|
||||||
|
func (msg syncFinished) String() string {
|
||||||
|
return "Sync completed…"
|
||||||
|
}
|
||||||
|
|
||||||
|
type fetchedVerificationKeys struct{}
|
||||||
|
|
||||||
|
func (msg fetchedVerificationKeys) String() string {
|
||||||
|
return "Successfully unlocked cross-signing keys…"
|
||||||
|
}
|
||||||
|
|
||||||
|
type successfullyVerified struct{}
|
||||||
|
|
||||||
|
func (msg successfullyVerified) String() string {
|
||||||
|
return "Successfully self-signed. This device is now trusted by other devices…"
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue