Files
plumber/internal/mail/recording.go
T
codegirl007 3dde9f79f4
CI / test (pull_request) Successful in 6m23s
Generalize post reply notifications.
Notify direct parent authors throughout threaded conversations while skipping self-replies, edits, and recipients without email.
2026-08-27 08:57:16 -07:00

35 lines
605 B
Go

package mail
import (
"context"
"sync"
)
// Recording is a test Notifier that records calls.
type Recording struct {
mu sync.Mutex
Msgs []PostReply
}
func (r *Recording) NotifyPostReply(_ context.Context, msg PostReply) error {
r.mu.Lock()
defer r.mu.Unlock()
r.Msgs = append(r.Msgs, msg)
return nil
}
func (r *Recording) Len() int {
r.mu.Lock()
defer r.mu.Unlock()
return len(r.Msgs)
}
// Snapshot returns a copy of recorded messages.
func (r *Recording) Snapshot() []PostReply {
r.mu.Lock()
defer r.mu.Unlock()
out := make([]PostReply, len(r.Msgs))
copy(out, r.Msgs)
return out
}