login*: set device config on login clients

This commit is contained in:
Tulir Asokan
2025-12-03 15:59:38 +02:00
parent 2004085312
commit 1ecb9e8b64
3 changed files with 13 additions and 7 deletions
+11 -7
View File
@@ -138,6 +138,16 @@ func (u UpdateDispatcher) Handle(ctx context.Context, updates tg.UpdatesClass) e
var messageLinkRegex = regexp.MustCompile(`^https?://t(?:elegram)?\.(?:me|dog)/([A-Za-z][A-Za-z0-9_]{3,31}[A-Za-z0-9]|[Cc]/[0-9]{1,20})/([0-9]{1,20})$`)
func (tg *TelegramConnector) deviceConfig() telegram.DeviceConfig {
return telegram.DeviceConfig{
DeviceModel: tg.Config.DeviceInfo.DeviceModel,
SystemVersion: tg.Config.DeviceInfo.SystemVersion,
AppVersion: tg.Config.DeviceInfo.AppVersion,
SystemLangCode: tg.Config.DeviceInfo.SystemLangCode,
LangCode: tg.Config.DeviceInfo.LangCode,
}
}
func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridgev2.UserLogin) (*TelegramClient, error) {
telegramUserID, err := ids.ParseUserLoginID(login.ID)
if err != nil {
@@ -265,13 +275,7 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge
OnAuthError: client.onAuthError,
PingTimeout: time.Duration(tc.Config.Ping.TimeoutSeconds) * time.Second,
PingInterval: time.Duration(tc.Config.Ping.IntervalSeconds) * time.Second,
Device: telegram.DeviceConfig{
DeviceModel: tc.Config.DeviceInfo.DeviceModel,
SystemVersion: tc.Config.DeviceInfo.SystemVersion,
AppVersion: tc.Config.DeviceInfo.AppVersion,
SystemLangCode: tc.Config.DeviceInfo.SystemLangCode,
LangCode: tc.Config.DeviceInfo.LangCode,
},
Device: tc.deviceConfig(),
})
client.telegramFmtParams = &telegramfmt.FormatParams{
+1
View File
@@ -85,6 +85,7 @@ func (p *PhoneLogin) SubmitUserInput(ctx context.Context, input map[string]strin
p.authClient = telegram.NewClient(p.main.Config.APIID, p.main.Config.APIHash, telegram.Options{
CustomSessionStorage: &p.authData,
Logger: zap.New(zerozap.New(zerolog.Ctx(ctx).With().Str("component", "telegram_phone_login_client").Logger())),
Device: p.main.deviceConfig(),
})
p.authClientCtx, p.authClientCancel = context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))
+1
View File
@@ -85,6 +85,7 @@ func (q *QRLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error) {
CustomSessionStorage: &q.authData,
UpdateHandler: updateManager,
Logger: zaplog,
Device: q.main.deviceConfig(),
})
q.authClientCtx, q.authClientCancel = context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))