diff --git a/pkg/connector/client.go b/pkg/connector/client.go index d54cc5df..deade5a0 100644 --- a/pkg/connector/client.go +++ b/pkg/connector/client.go @@ -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{ diff --git a/pkg/connector/loginphone.go b/pkg/connector/loginphone.go index f757fa0f..e3f29bee 100644 --- a/pkg/connector/loginphone.go +++ b/pkg/connector/loginphone.go @@ -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")) diff --git a/pkg/connector/loginqr.go b/pkg/connector/loginqr.go index d1024f22..6b3e1e06 100644 --- a/pkg/connector/loginqr.go +++ b/pkg/connector/loginqr.go @@ -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"))