mirror of
https://github.com/zitadel/zitadel.git
synced 2025-02-28 16:27:23 +00:00
fix(query): show views and failed events (#3743)
* fix(system): show views and failed events * fix: set correct database on failed events and views
This commit is contained in:
parent
e3e0207318
commit
ed36680ea1
@ -165,7 +165,7 @@ func startAPIs(ctx context.Context, router *mux.Router, commands *command.Comman
|
||||
if err := apis.RegisterServer(ctx, system.CreateServer(commands, queries, adminRepo, config.Database.Database, config.DefaultInstance)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := apis.RegisterServer(ctx, admin.CreateServer(commands, queries, adminRepo, config.ExternalSecure, keys.User)); err != nil {
|
||||
if err := apis.RegisterServer(ctx, admin.CreateServer(config.Database.Database, commands, queries, adminRepo, config.ExternalSecure, keys.User)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := apis.RegisterServer(ctx, management.CreateServer(commands, queries, config.SystemDefaults, keys.User, config.ExternalSecure, oidc.HandlerPrefix, config.AuditLogRetention)); err != nil {
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
var dbList = []string{"auth", "authz", "adminapi", "notification"}
|
||||
var dbList = []string{"auth", "adminapi", "notification"}
|
||||
|
||||
type AdministratorRepo struct {
|
||||
View *view.View
|
||||
|
@ -18,14 +18,13 @@ func (s *Server) ListFailedEvents(ctx context.Context, req *admin_pb.ListFailedE
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
convertedNew := FailedEventsToPb(failedEvents)
|
||||
convertedOld = append(convertedOld, convertedNew...)
|
||||
return &admin_pb.ListFailedEventsResponse{Result: convertedOld}, nil
|
||||
convertedNew := FailedEventsToPb(s.database, failedEvents)
|
||||
return &admin_pb.ListFailedEventsResponse{Result: append(convertedOld, convertedNew...)}, nil
|
||||
}
|
||||
|
||||
func (s *Server) RemoveFailedEvent(ctx context.Context, req *admin_pb.RemoveFailedEventRequest) (*admin_pb.RemoveFailedEventResponse, error) {
|
||||
var err error
|
||||
if req.Database != "zitadel" {
|
||||
if req.Database != s.database {
|
||||
err = s.administrator.RemoveFailedEvent(ctx, RemoveFailedEventRequestToModel(req))
|
||||
} else {
|
||||
err = s.query.RemoveFailedEvent(ctx, req.ViewName, req.FailedSequence)
|
||||
|
@ -24,17 +24,17 @@ func FailedEventViewToPb(failedEvent *model.FailedEvent) *admin_pb.FailedEvent {
|
||||
}
|
||||
}
|
||||
|
||||
func FailedEventsToPb(failedEvents *query.FailedEvents) []*admin_pb.FailedEvent {
|
||||
func FailedEventsToPb(database string, failedEvents *query.FailedEvents) []*admin_pb.FailedEvent {
|
||||
events := make([]*admin_pb.FailedEvent, len(failedEvents.FailedEvents))
|
||||
for i, failedEvent := range failedEvents.FailedEvents {
|
||||
events[i] = FailedEventToPb(failedEvent)
|
||||
events[i] = FailedEventToPb(database, failedEvent)
|
||||
}
|
||||
return events
|
||||
}
|
||||
|
||||
func FailedEventToPb(failedEvent *query.FailedEvent) *admin_pb.FailedEvent {
|
||||
func FailedEventToPb(database string, failedEvent *query.FailedEvent) *admin_pb.FailedEvent {
|
||||
return &admin_pb.FailedEvent{
|
||||
Database: "zitadel",
|
||||
Database: database,
|
||||
ViewName: failedEvent.ProjectionName,
|
||||
FailedSequence: failedEvent.FailedSequence,
|
||||
FailureCount: failedEvent.FailureCount,
|
||||
|
@ -24,6 +24,7 @@ var _ admin.AdminServiceServer = (*Server)(nil)
|
||||
|
||||
type Server struct {
|
||||
admin.UnimplementedAdminServiceServer
|
||||
database string
|
||||
command *command.Commands
|
||||
query *query.Queries
|
||||
administrator repository.AdministratorRepository
|
||||
@ -35,13 +36,16 @@ type Config struct {
|
||||
Repository eventsourcing.Config
|
||||
}
|
||||
|
||||
func CreateServer(command *command.Commands,
|
||||
func CreateServer(
|
||||
database string,
|
||||
command *command.Commands,
|
||||
query *query.Queries,
|
||||
repo repository.Repository,
|
||||
externalSecure bool,
|
||||
userCodeAlg crypto.EncryptionAlgorithm,
|
||||
) *Server {
|
||||
return &Server{
|
||||
database: database,
|
||||
command: command,
|
||||
query: query,
|
||||
administrator: repo,
|
||||
|
@ -12,7 +12,7 @@ func (s *Server) ListViews(ctx context.Context, _ *admin_pb.ListViewsRequest) (*
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
convertedCurrentSequences := CurrentSequencesToPb(currentSequences)
|
||||
convertedCurrentSequences := CurrentSequencesToPb(s.database, currentSequences)
|
||||
views, err := s.administrator.GetViews()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -25,17 +25,17 @@ func ViewToPb(view *model.View) *admin_pb.View {
|
||||
}
|
||||
}
|
||||
|
||||
func CurrentSequencesToPb(currentSequences *query.CurrentSequences) []*admin_pb.View {
|
||||
func CurrentSequencesToPb(database string, currentSequences *query.CurrentSequences) []*admin_pb.View {
|
||||
v := make([]*admin_pb.View, len(currentSequences.CurrentSequences))
|
||||
for i, currentSequence := range currentSequences.CurrentSequences {
|
||||
v[i] = CurrentSequenceToPb(currentSequence)
|
||||
v[i] = CurrentSequenceToPb(database, currentSequence)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func CurrentSequenceToPb(currentSequence *query.CurrentSequence) *admin_pb.View {
|
||||
func CurrentSequenceToPb(database string, currentSequence *query.CurrentSequence) *admin_pb.View {
|
||||
return &admin_pb.View{
|
||||
Database: "zitadel",
|
||||
Database: database,
|
||||
ViewName: currentSequence.ProjectionName,
|
||||
ProcessedSequence: currentSequence.CurrentSequence,
|
||||
EventTimestamp: timestamppb.New(currentSequence.Timestamp),
|
||||
|
@ -18,14 +18,13 @@ func (s *Server) ListFailedEvents(ctx context.Context, req *system_pb.ListFailed
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
convertedNew := FailedEventsToPb(failedEvents)
|
||||
convertedOld = append(convertedOld, convertedNew...)
|
||||
return &system_pb.ListFailedEventsResponse{Result: convertedOld}, nil
|
||||
convertedNew := FailedEventsToPb(s.database, failedEvents)
|
||||
return &system_pb.ListFailedEventsResponse{Result: append(convertedOld, convertedNew...)}, nil
|
||||
}
|
||||
|
||||
func (s *Server) RemoveFailedEvent(ctx context.Context, req *system_pb.RemoveFailedEventRequest) (*system_pb.RemoveFailedEventResponse, error) {
|
||||
var err error
|
||||
if req.Database != "zitadel" {
|
||||
if req.Database != s.database {
|
||||
err = s.administrator.RemoveFailedEvent(ctx, RemoveFailedEventRequestToModel(req))
|
||||
} else {
|
||||
err = s.query.RemoveFailedEvent(ctx, req.ViewName, req.FailedSequence)
|
||||
|
@ -24,17 +24,17 @@ func FailedEventViewToPb(failedEvent *model.FailedEvent) *system_pb.FailedEvent
|
||||
}
|
||||
}
|
||||
|
||||
func FailedEventsToPb(failedEvents *query.FailedEvents) []*system_pb.FailedEvent {
|
||||
func FailedEventsToPb(database string, failedEvents *query.FailedEvents) []*system_pb.FailedEvent {
|
||||
events := make([]*system_pb.FailedEvent, len(failedEvents.FailedEvents))
|
||||
for i, failedEvent := range failedEvents.FailedEvents {
|
||||
events[i] = FailedEventToPb(failedEvent)
|
||||
events[i] = FailedEventToPb(database, failedEvent)
|
||||
}
|
||||
return events
|
||||
}
|
||||
|
||||
func FailedEventToPb(failedEvent *query.FailedEvent) *system_pb.FailedEvent {
|
||||
func FailedEventToPb(database string, failedEvent *query.FailedEvent) *system_pb.FailedEvent {
|
||||
return &system_pb.FailedEvent{
|
||||
Database: "zitadel",
|
||||
Database: database,
|
||||
ViewName: failedEvent.ProjectionName,
|
||||
FailedSequence: failedEvent.FailedSequence,
|
||||
FailureCount: failedEvent.FailureCount,
|
||||
|
@ -12,7 +12,7 @@ func (s *Server) ListViews(ctx context.Context, _ *system_pb.ListViewsRequest) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
convertedCurrentSequences := CurrentSequencesToPb(currentSequences)
|
||||
convertedCurrentSequences := CurrentSequencesToPb(s.database, currentSequences)
|
||||
views, err := s.administrator.GetViews()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -25,17 +25,17 @@ func ViewToPb(view *model.View) *system_pb.View {
|
||||
}
|
||||
}
|
||||
|
||||
func CurrentSequencesToPb(currentSequences *query.CurrentSequences) []*system_pb.View {
|
||||
func CurrentSequencesToPb(database string, currentSequences *query.CurrentSequences) []*system_pb.View {
|
||||
v := make([]*system_pb.View, len(currentSequences.CurrentSequences))
|
||||
for i, currentSequence := range currentSequences.CurrentSequences {
|
||||
v[i] = CurrentSequenceToPb(currentSequence)
|
||||
v[i] = CurrentSequenceToPb(database, currentSequence)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func CurrentSequenceToPb(currentSequence *query.CurrentSequence) *system_pb.View {
|
||||
func CurrentSequenceToPb(database string, currentSequence *query.CurrentSequence) *system_pb.View {
|
||||
return &system_pb.View{
|
||||
Database: "zitadel",
|
||||
Database: database,
|
||||
ViewName: currentSequence.ProjectionName,
|
||||
ProcessedSequence: currentSequence.CurrentSequence,
|
||||
EventTimestamp: timestamppb.New(currentSequence.Timestamp),
|
||||
|
Loading…
x
Reference in New Issue
Block a user