From 274141a1b07bb50e954cf1adfa7c053c1a5c04b7 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Mon, 29 Dec 2025 23:12:33 +0200 Subject: [PATCH] client: add lock for onTransfer There should never be multiple clients to actually need this, but just in case --- pkg/connector/client.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/connector/client.go b/pkg/connector/client.go index cc23e99d..969ac328 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -104,6 +104,8 @@ type TelegramClient struct { contactsLock sync.Mutex lastContactReq time.Time + dcTransferLock sync.Mutex + takeoutLock sync.Mutex takeoutAccepted *exsync.Event stopTakeoutTimer *time.Timer @@ -256,6 +258,7 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge OnDead: client.onDead, OnSession: client.onSession, OnConnected: client.onConnected, + OnTransfer: client.onTransfer, PingCallback: client.onPing, OnAuthError: client.onAuthError, PingTimeout: time.Duration(tc.Config.Ping.TimeoutSeconds) * time.Second, @@ -501,6 +504,13 @@ func (t *TelegramClient) onConnected(self *tg.User) { t.userLogin.BridgeState.Send(status.BridgeState{StateEvent: status.StateConnected}) } +func (t *TelegramClient) onTransfer(ctx context.Context, _ *telegram.Client, fn func(context.Context) error) error { + t.userLogin.Log.Trace().Msg("Doing DC auth transfer") + t.dcTransferLock.Lock() + defer t.dcTransferLock.Unlock() + return fn(ctx) +} + func (t *TelegramClient) onSession() { t.userLogin.Log.Debug().Msg("Got session created event") }