2023-03-28 22:09:06 +00:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
)
|
|
|
|
|
2023-07-06 06:38:13 +00: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-28 22:09:06 +00:00
|
|
|
events, err := n.es.Filter(
|
|
|
|
ctx,
|
|
|
|
eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
|
|
|
InstanceID(event.Aggregate().InstanceID).
|
|
|
|
AddQuery().
|
2023-07-06 06:38:13 +00:00
|
|
|
AggregateTypes(aggregateType).
|
2023-03-28 22:09:06 +00:00
|
|
|
AggregateIDs(event.Aggregate().ID).
|
|
|
|
SequenceGreater(event.Sequence()).
|
|
|
|
EventTypes(eventTypes...).
|
|
|
|
EventData(data).
|
|
|
|
Builder(),
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
return len(events) > 0, nil
|
|
|
|
}
|