Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ All notable HyperMeow changes are documented here. HyperMeow uses commit pseudo-
- Preserve reported newsletter counter presence, explicit zeros and distinct view definitions. Omit malformed or ambiguous observations, including duplicate view definitions, instead of reporting fabricated zeros or truncated reaction lists.
- Copy group-cache metadata under its lock before send-permission checks, including participant and admin slices, so notifications cannot race those reads.
- Stop automatic reconnect and emit `CATRefreshError` to generic and connection-scoped observers when a 413/414 failure cannot refresh its token, including when `RefreshCAT` is unset. The missing callback returns `ErrCATRefreshUnavailable` instead of retrying unchanged credentials.
- Protect the unified-session interval check during concurrent sends.
- Keep connection handler completion pending until an active handler exits, and process retired stream errors before automatic reconnect decisions. Manual disconnect retains its five-second wait bound.
- Keep the newest pairing secret through bursts of rotation notifications and refresh the active QR code.
- Report the destination in `SendFBMessage` responses and decrypt full bot edits using their target message ID.
Expand Down
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type Client struct {
EnableDecryptedEventBuffer bool
synchronousMessageNameUpdates atomic.Bool
lastDecryptedBufferClear time.Time
unifiedSessionLock sync.Mutex
lastUnifiedSessionSend time.Time
UnifiedSessionInterval time.Duration

Expand Down Expand Up @@ -1345,10 +1346,13 @@ func (cli *Client) sendUnifiedSession(checkLastSend bool) {
if cli == nil {
return
}
cli.unifiedSessionLock.Lock()
if checkLastSend && time.Since(cli.lastUnifiedSessionSend) < cli.UnifiedSessionInterval {
cli.unifiedSessionLock.Unlock()
return
}
cli.lastUnifiedSessionSend = time.Now()
cli.unifiedSessionLock.Unlock()
node := waBinary.Node{
Tag: "ib",
Attrs: waBinary.Attrs{},
Expand Down
30 changes: 30 additions & 0 deletions client_unified_session_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package whatsmeow

import (
"slices"
"sync"
"testing"
"time"
)

func TestConcurrentUnifiedSessionChecksRespectInterval(t *testing.T) {
cli, _, sent := newTestRemote(t)
cli.UnifiedSessionInterval = time.Hour
start := make(chan struct{})
var workers sync.WaitGroup
for range 32 {
workers.Go(func() {
<-start
cli.sendUnifiedSession(true)
})
}
close(start)
workers.Wait()
if tags := sent.tags(); !slices.Equal(tags, []string{"ib:"}) {
t.Fatalf("concurrent interval checks sent %v", tags)
}
cli.sendUnifiedSession(false)
if len(sent.tags()) != 2 {
t.Fatal("explicit unified-session send was incorrectly suppressed")
}
}
Loading