Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

login: open new WS and refresh QR code after 45s #585

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/connector/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package connector
import (
"context"
"fmt"
"time"

"github.com/google/uuid"
"maunium.net/go/mautrix/bridge/status"
Expand Down Expand Up @@ -50,6 +51,7 @@ type QRLogin struct {
Main *SignalConnector
cancelChan context.CancelFunc
ProvChan chan signalmeow.ProvisioningResponse
newQRCount int

ProvData *store.DeviceData
}
Expand Down Expand Up @@ -139,6 +141,17 @@ func (qr *QRLogin) qrWait(ctx context.Context) (*bridgev2.LoginStep, error) {
Type: bridgev2.LoginDisplayTypeNothing,
},
}, nil

// Server will timeout the request after 60 seconds, but Signal Desktop opens
// a new socket and gets a new QR code after 45 seconds. We should do the same.
case <-time.After(45 * time.Second):
qr.cancelChan()
qr.newQRCount++
if qr.newQRCount >= 6 {
return nil, fmt.Errorf("too many QR code refreshes")
}
return qr.Start(ctx)

case <-ctx.Done():
qr.cancelChan()
return nil, ctx.Err()
Expand Down
Loading