login: always set update handler

This commit is contained in:
Tulir Asokan
2026-04-14 17:26:33 +03:00
parent b761f04621
commit 3f155672a7
3 changed files with 11 additions and 11 deletions
+8 -8
View File
@@ -26,6 +26,7 @@ import (
"time"
"github.com/rs/zerolog"
"go.mau.fi/util/ptr"
"go.mau.fi/zerozap"
"go.uber.org/zap"
"maunium.net/go/mautrix/bridgev2"
@@ -121,19 +122,18 @@ func (bl *baseLogin) Cancel() {
func (bl *baseLogin) makeClient(ctx context.Context, dispatcher *tg.UpdateDispatcher) error {
log := zerolog.Ctx(ctx)
zaplog := zap.New(zerozap.NewWithLevels(*log, zapLevelMap))
var updateManager *updates.Manager
if dispatcher != nil {
updateManager = updates.New(updates.Config{
Handler: dispatcher,
Logger: zaplog.Named("login_update_manager"),
})
if dispatcher == nil {
dispatcher = ptr.Ptr(tg.NewUpdateDispatcher())
}
bl.client = telegram.NewClient(bl.main.Config.APIID, bl.main.Config.APIHash, telegram.Options{
CustomSessionStorage: &bl.session,
Logger: zaplog,
Device: bl.main.deviceConfig(),
UpdateHandler: updateManager,
NoUpdates: true,
UpdateHandler: updates.New(updates.Config{
Handler: dispatcher,
Logger: zaplog.Named("login_update_manager"),
}),
NoUpdates: true,
})
bl.ctx, bl.cancel = context.WithTimeoutCause(log.WithContext(bl.main.Bridge.BackgroundCtx), LoginTimeout, ErrLoginTimeout)