2023-03-29 00:09:06 +02:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
)
|
|
|
|
|
2023-07-06 08:38:13 +02:00
|
|
|
func (n *NotificationQueries) IsAlreadyHandled(ctx context.Context, event eventstore.Event, data map[string]interface{}, aggregateType eventstore.AggregateType, eventTypes ...eventstore.EventType) (bool, error) {
|
2023-03-29 00:09:06 +02:00
|
|
|
events, err := n.es.Filter(
|
|
|
|
ctx,
|
|
|
|
eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
|
|
|
InstanceID(event.Aggregate().InstanceID).
|
|
|
|
AddQuery().
|
2023-07-06 08:38:13 +02:00
|
|
|
AggregateTypes(aggregateType).
|
2023-03-29 00:09:06 +02:00
|
|
|
AggregateIDs(event.Aggregate().ID).
|
|
|
|
SequenceGreater(event.Sequence()).
|
|
|
|
EventTypes(eventTypes...).
|
|
|
|
EventData(data).
|
|
|
|
Builder(),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
return len(events) > 0, nil
|
|
|
|
}
|