backfill: stop history sync portal creation if client disconnects

This commit is contained in:
Tulir Asokan 2024-11-14 14:29:18 +02:00
parent 1a48dc16ba
commit 5aee9f2eff
3 changed files with 10 additions and 3 deletions

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/rs/zerolog v1.33.0
go.mau.fi/util v0.8.2-0.20241113135441-636f8643f367
go.mau.fi/webp v0.1.0
go.mau.fi/whatsmeow v0.0.0-20241113162158-4dcaa22ec558
go.mau.fi/whatsmeow v0.0.0-20241114122515-3c0f25d54c22
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
golang.org/x/image v0.22.0
golang.org/x/net v0.31.0

4
go.sum
View file

@ -69,8 +69,8 @@ go.mau.fi/util v0.8.2-0.20241113135441-636f8643f367 h1:GU0TYiAOU79p6r3jf3e4k5cdg
go.mau.fi/util v0.8.2-0.20241113135441-636f8643f367/go.mod h1:SVzC++wSl8Yq4YVQRClLPa1frNpSVDVP6mfkw/OvDbc=
go.mau.fi/webp v0.1.0 h1:BHObH/DcFntT9KYun5pDr0Ot4eUZO8k2C7eP7vF4ueA=
go.mau.fi/webp v0.1.0/go.mod h1:e42Z+VMFrUMS9cpEwGRIor+lQWO8oUAyPyMtcL+NMt8=
go.mau.fi/whatsmeow v0.0.0-20241113162158-4dcaa22ec558 h1:gFrc7ut4MYCHvI0j+WIkEwHdaept0MJ5DSbDfx8vNiE=
go.mau.fi/whatsmeow v0.0.0-20241113162158-4dcaa22ec558/go.mod h1:TsBdbxqTsOTiKXj2M/ipWWFGKebU+WcipK4LZnHfEJ4=
go.mau.fi/whatsmeow v0.0.0-20241114122515-3c0f25d54c22 h1:MqyzS+gnDLTGfbmQvmzbe7ZcsyEgkw2WDTWaC3AVnOo=
go.mau.fi/whatsmeow v0.0.0-20241114122515-3c0f25d54c22/go.mod h1:TsBdbxqTsOTiKXj2M/ipWWFGKebU+WcipK4LZnHfEJ4=
go.mau.fi/zeroconfig v0.1.3 h1:As9wYDKmktjmNZW5i1vn8zvJlmGKHeVxHVIBMXsm4kM=
go.mau.fi/zeroconfig v0.1.3/go.mod h1:NcSJkf180JT+1IId76PcMuLTNa1CzsFFZ0nBygIQM70=
golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ=

View file

@ -205,6 +205,13 @@ func (wa *WhatsAppClient) createPortalsFromHistorySync(ctx context.Context) {
var wg sync.WaitGroup
wg.Add(len(conversations))
for i := 0; i < len(conversations); i++ {
if ctx.Err() != nil {
log.Warn().Err(ctx.Err()).Msg("Context cancelled, stopping history sync portal creation")
return
} else if wa.Client == nil {
log.Warn().Msg("Client is nil, stopping history sync portal creation")
return
}
conv := conversations[i]
if conv.ChatJID == types.StatusBroadcastJID && !wa.Main.Config.EnableStatusBroadcast {
wg.Done()