WithCheckDuplicate(), let's see if this works.

This commit is contained in:
fiatjaf
2025-01-15 14:26:00 -03:00
parent ba38c28b99
commit e1971d12c0
4 changed files with 21 additions and 36 deletions

View File

@ -225,8 +225,8 @@ func (r *Relay) ConnectWithTLS(ctx context.Context, tlsConfig *tls.Config) error
// as we skip handling duplicate events
subid := extractSubID(message)
subscription, ok := r.Subscriptions.Load(subIdToSerial(subid))
if ok && subscription.CheckDuplicate != nil {
if !subscription.CheckDuplicate(extractEventID(message[10+len(subid):]), r.URL) {
if ok && subscription.checkDuplicate != nil {
if !subscription.checkDuplicate(extractEventID(message[10+len(subid):]), r.URL) {
continue
}
}
@ -426,6 +426,8 @@ func (r *Relay) PrepareSubscription(ctx context.Context, filters Filters, opts .
switch o := opt.(type) {
case WithLabel:
label = string(o)
case WithCheckDuplicate:
sub.checkDuplicate = o
}
}