mirror of
https://github.com/mautrix/telegram.git
synced 2026-05-17 07:25:46 +03:00
dependencies: update go
Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
4
.github/workflows/go.yml
vendored
4
.github/workflows/go.yml
vendored
@@ -11,8 +11,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
go-version: ["1.22", "1.23"]
|
||||
name: Lint ${{ matrix.go-version == '1.23' && '(latest)' || '(old)' }}
|
||||
go-version: ["1.23", "1.24"]
|
||||
name: Lint ${{ matrix.go-version == '1.24' && '(latest)' || '(old)' }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
4
go.mod
4
go.mod
@@ -1,8 +1,8 @@
|
||||
module go.mau.fi/mautrix-telegram
|
||||
|
||||
go 1.22.0
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.23.5
|
||||
toolchain go1.24.0
|
||||
|
||||
require (
|
||||
github.com/gorilla/mux v1.8.0
|
||||
|
||||
@@ -354,9 +354,7 @@ func NewTelegramClient(ctx context.Context, tc *TelegramConnector, login *bridge
|
||||
// connectTelegramClient blocks until client is connected, calling Run
|
||||
// internally.
|
||||
// Technique from: https://github.com/gotd/contrib/blob/master/bg/connect.go
|
||||
func connectTelegramClient(ctx context.Context, client *telegram.Client) (context.Context, context.CancelFunc, error) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
func connectTelegramClient(ctx context.Context, cancel context.CancelFunc, client *telegram.Client) error {
|
||||
errC := make(chan error, 1)
|
||||
initDone := make(chan struct{})
|
||||
go func() {
|
||||
@@ -374,14 +372,13 @@ func connectTelegramClient(ctx context.Context, client *telegram.Client) (contex
|
||||
select {
|
||||
case <-ctx.Done(): // context canceled
|
||||
cancel()
|
||||
return nil, func() {}, fmt.Errorf("context cancelled before init done: %w", ctx.Err())
|
||||
return fmt.Errorf("context cancelled before init done: %w", ctx.Err())
|
||||
case err := <-errC: // startup timeout
|
||||
cancel()
|
||||
return nil, func() {}, fmt.Errorf("client connection timeout: %w", err)
|
||||
return fmt.Errorf("client connection timeout: %w", err)
|
||||
case <-initDone: // init done
|
||||
}
|
||||
|
||||
return ctx, cancel, nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TelegramClient) onDead() {
|
||||
@@ -483,8 +480,8 @@ func (t *TelegramClient) Connect(ctx context.Context) {
|
||||
zerolog.Ctx(ctx).Info().Int64("user_id", t.telegramUserID).Msg("Connecting client")
|
||||
|
||||
var err error
|
||||
t.clientCtx, t.clientCancel, err = connectTelegramClient(ctx, t.client)
|
||||
if err != nil {
|
||||
t.clientCtx, t.clientCancel = context.WithCancel(ctx)
|
||||
if err = connectTelegramClient(t.clientCtx, t.clientCancel, t.client); err != nil {
|
||||
t.sendBadCredentialsOrUnknownError(err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -67,9 +67,9 @@ func (p *PhoneLogin) SubmitUserInput(ctx context.Context, input map[string]strin
|
||||
Logger: zap.New(zerozap.New(zerolog.Ctx(ctx).With().Str("component", "telegram_phone_login_client").Logger())),
|
||||
})
|
||||
var err error
|
||||
authClientContext, _ := context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))
|
||||
ctx, p.authClientCancel, err = connectTelegramClient(authClientContext, p.authClient)
|
||||
if err != nil {
|
||||
var authClientContext context.Context
|
||||
authClientContext, p.authClientCancel = context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))
|
||||
if err = connectTelegramClient(authClientContext, p.authClientCancel, p.authClient); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
sentCode, err := p.authClient.Auth().SendCode(ctx, p.phone, auth.SendCodeOptions{})
|
||||
|
||||
@@ -68,9 +68,9 @@ func (q *QRLogin) Start(ctx context.Context) (*bridgev2.LoginStep, error) {
|
||||
})
|
||||
|
||||
var err error
|
||||
authClientContext, _ := context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))
|
||||
q.authClientCtx, q.authClientCancel, err = connectTelegramClient(authClientContext, q.authClient)
|
||||
if err != nil {
|
||||
var authClientContext context.Context
|
||||
authClientContext, q.authClientCancel = context.WithTimeoutCause(log.WithContext(context.Background()), time.Hour, errors.New("phone login took over one hour"))
|
||||
if err = connectTelegramClient(authClientContext, q.authClientCancel, q.authClient); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user