matrix: add log for matrix crypto store init

deleting the crypto DB resulted in InitMatrixCrypto taking ages, added a
Initing/Inited log pair around the function so it's obvious this is the
culprit if any one else faces the same thing.
This commit is contained in:
Harvey Tindall
2025-08-31 17:58:13 +01:00
parent 87c0f54a8d
commit 0783749e6e
4 changed files with 19 additions and 10 deletions

View File

@@ -70,6 +70,8 @@ const (
FailedInitTelegram = "Failed to initialize Telegram daemon: %v"
InitMatrix = "Initialized Matrix daemon"
FailedInitMatrix = "Failed to initialize Matrix daemon: %v"
InitingMatrixCrypto = "Initializing Matrix encryption store"
InitMatrixCrypto = "Initialized Matrix encryption store"
InitRouter = "Initializing router"
LoadRoutes = "Loading Routes"

View File

@@ -101,7 +101,7 @@ func newMatrixDaemon(app *appContext) (d *MatrixDaemon, err error) {
d.languages[id.RoomID(user.RoomID)] = user.Lang
}
}
err = InitMatrixCrypto(d)
err = InitMatrixCrypto(d, app.info)
return
}

View File

@@ -6,6 +6,8 @@ package main
import (
"context"
"github.com/hrfee/jfa-go/logger"
lm "github.com/hrfee/jfa-go/logmessages"
_ "github.com/mattn/go-sqlite3"
"maunium.net/go/mautrix/crypto/cryptohelper"
"maunium.net/go/mautrix/event"
@@ -22,7 +24,8 @@ func BuildTagsE2EE() {
func MatrixE2EE() bool { return true }
func InitMatrixCrypto(d *MatrixDaemon) error {
func InitMatrixCrypto(d *MatrixDaemon, logger *logger.Logger) error {
logger.Printf(lm.InitingMatrixCrypto)
d.Encryption = d.app.config.Section("matrix").Key("encryption").MustBool(false)
if !d.Encryption {
// return fmt.Errorf("encryption disabled")
@@ -45,6 +48,7 @@ func InitMatrixCrypto(d *MatrixDaemon) error {
d.bot.Crypto = d.crypto.helper
d.Encryption = true
logger.Printf(lm.InitMatrixCrypto)
return nil
}

View File

@@ -3,7 +3,10 @@
package main
import "maunium.net/go/mautrix/id"
import (
"github.com/hrfee/jfa-go/logger"
"maunium.net/go/mautrix/id"
)
type Crypto struct{}
@@ -11,7 +14,7 @@ func BuildTagsE2EE() {}
func MatrixE2EE() bool { return false }
func InitMatrixCrypto(d *MatrixDaemon) (err error) {
func InitMatrixCrypto(d *MatrixDaemon, logger *logger.Logger) (err error) {
d.Encryption = false
return
}