2022-04-21 10:37:39 +00:00
|
|
|
package system
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/query"
|
|
|
|
system_pb "github.com/zitadel/zitadel/pkg/grpc/system"
|
2022-04-21 10:37:39 +00:00
|
|
|
)
|
|
|
|
|
2022-11-18 12:49:38 +00:00
|
|
|
func (s *Server) ListFailedEvents(ctx context.Context, _ *system_pb.ListFailedEventsRequest) (*system_pb.ListFailedEventsResponse, error) {
|
|
|
|
failedEventsOld, err := s.administrator.GetFailedEvents(ctx, "")
|
2022-04-21 10:37:39 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
convertedOld := FailedEventsViewToPb(failedEventsOld)
|
|
|
|
|
|
|
|
failedEvents, err := s.query.SearchFailedEvents(ctx, new(query.FailedEventSearchQueries))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2022-05-31 14:33:50 +00:00
|
|
|
convertedNew := FailedEventsToPb(s.database, failedEvents)
|
|
|
|
return &system_pb.ListFailedEventsResponse{Result: append(convertedOld, convertedNew...)}, nil
|
2022-04-21 10:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Server) RemoveFailedEvent(ctx context.Context, req *system_pb.RemoveFailedEventRequest) (*system_pb.RemoveFailedEventResponse, error) {
|
|
|
|
var err error
|
2022-05-31 14:33:50 +00:00
|
|
|
if req.Database != s.database {
|
2022-04-21 10:37:39 +00:00
|
|
|
err = s.administrator.RemoveFailedEvent(ctx, RemoveFailedEventRequestToModel(req))
|
|
|
|
} else {
|
2022-11-18 12:49:38 +00:00
|
|
|
err = s.query.RemoveFailedEvent(ctx, req.ViewName, req.InstanceId, req.FailedSequence)
|
2022-04-21 10:37:39 +00:00
|
|
|
}
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &system_pb.RemoveFailedEventResponse{}, nil
|
|
|
|
}
|