mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
fix(current_sequence): no error if not found (#3740)
This commit is contained in:
parent
81c0ca3337
commit
16c86149be
@ -4,13 +4,12 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/user"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/idp"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
||||
policy_grpc "github.com/zitadel/zitadel/internal/api/grpc/policy"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/user"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
|
||||
)
|
||||
|
||||
@ -63,10 +62,17 @@ func (s *Server) AddIDPToLoginPolicy(ctx context.Context, req *admin_pb.AddIDPTo
|
||||
|
||||
func (s *Server) RemoveIDPFromLoginPolicy(ctx context.Context, req *admin_pb.RemoveIDPFromLoginPolicyRequest) (*admin_pb.RemoveIDPFromLoginPolicyResponse, error) {
|
||||
idpQuery, err := query.NewIDPUserLinkIDPIDSearchQuery(req.IdpId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
idps, err := s.query.IDPUserLinks(ctx, &query.IDPUserLinksSearchQuery{
|
||||
Queries: []query.SearchQuery{idpQuery},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
objectDetails, err := s.command.RemoveIDPProviderFromDefaultLoginPolicy(ctx, &domain.IDPProvider{IDPConfigID: req.IdpId}, user.ExternalIDPViewsToExternalIDPs(idps.Links)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -3,8 +3,6 @@ package admin
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
||||
org_grpc "github.com/zitadel/zitadel/internal/api/grpc/org"
|
||||
@ -12,7 +10,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
admin_pb "github.com/zitadel/zitadel/pkg/grpc/admin"
|
||||
obj_pb "github.com/zitadel/zitadel/pkg/grpc/object"
|
||||
)
|
||||
|
||||
func (s *Server) IsOrgUnique(ctx context.Context, req *admin_pb.IsOrgUniqueRequest) (*admin_pb.IsOrgUniqueResponse, error) {
|
||||
@ -38,12 +35,8 @@ func (s *Server) ListOrgs(ctx context.Context, req *admin_pb.ListOrgsRequest) (*
|
||||
return nil, err
|
||||
}
|
||||
return &admin_pb.ListOrgsResponse{
|
||||
Result: org_grpc.OrgViewsToPb(orgs.Orgs),
|
||||
Details: &obj_pb.ListDetails{
|
||||
TotalResult: orgs.Count,
|
||||
ProcessedSequence: orgs.Sequence,
|
||||
ViewTimestamp: timestamppb.New(orgs.Timestamp),
|
||||
},
|
||||
Result: org_grpc.OrgViewsToPb(orgs.Orgs),
|
||||
Details: object.ToListDetails(orgs.Count, orgs.Sequence, orgs.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -18,12 +18,8 @@ func (s *Server) ListMyLinkedIDPs(ctx context.Context, req *auth_pb.ListMyLinked
|
||||
return nil, err
|
||||
}
|
||||
return &auth_pb.ListMyLinkedIDPsResponse{
|
||||
Result: idp_grpc.IDPUserLinksToPb(links.Links),
|
||||
Details: object.ToListDetails(
|
||||
links.Count,
|
||||
links.Sequence,
|
||||
links.Timestamp,
|
||||
),
|
||||
Result: idp_grpc.IDPUserLinksToPb(links.Links),
|
||||
Details: object.ToListDetails(links.Count, links.Sequence, links.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/zitadel/zitadel/internal/api/authz"
|
||||
obj_grpc "github.com/zitadel/zitadel/internal/api/grpc/object"
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/object"
|
||||
user_grpc "github.com/zitadel/zitadel/internal/api/grpc/user"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
auth_pb "github.com/zitadel/zitadel/pkg/grpc/auth"
|
||||
@ -53,11 +53,7 @@ func (s *Server) ListMyMemberships(ctx context.Context, req *auth_pb.ListMyMembe
|
||||
return nil, err
|
||||
}
|
||||
return &auth_pb.ListMyMembershipsResponse{
|
||||
Result: user_grpc.MembershipsToMembershipsPb(response.Memberships),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
response.Count,
|
||||
response.Sequence,
|
||||
response.Timestamp,
|
||||
),
|
||||
Result: user_grpc.MembershipsToMembershipsPb(response.Memberships),
|
||||
Details: object.ToListDetails(response.Count, response.Sequence, response.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
@ -16,12 +16,8 @@ func (s *Server) ListMyRefreshTokens(ctx context.Context, req *auth.ListMyRefres
|
||||
return nil, err
|
||||
}
|
||||
return &auth.ListMyRefreshTokensResponse{
|
||||
Result: user_grpc.RefreshTokensToPb(res.Result),
|
||||
Details: object.ToListDetails(
|
||||
res.TotalResult,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: user_grpc.RefreshTokensToPb(res.Result),
|
||||
Details: object.ToListDetails(res.TotalResult, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -75,12 +75,8 @@ func (s *Server) ListMyMetadata(ctx context.Context, req *auth_pb.ListMyMetadata
|
||||
return nil, err
|
||||
}
|
||||
return &auth_pb.ListMyMetadataResponse{
|
||||
Result: metadata.MetadataListToPb(res.Metadata),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
res.Count,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: metadata.MetadataListToPb(res.Metadata),
|
||||
Details: obj_grpc.ToListDetails(res.Count, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -133,12 +129,8 @@ func (s *Server) ListMyUserGrants(ctx context.Context, req *auth_pb.ListMyUserGr
|
||||
return nil, err
|
||||
}
|
||||
return &auth_pb.ListMyUserGrantsResponse{
|
||||
Result: UserGrantsToPb(res.UserGrants),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
res.Count,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: UserGrantsToPb(res.UserGrants),
|
||||
Details: obj_grpc.ToListDetails(res.Count, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -134,12 +134,8 @@ func (s *Server) ListOrgDomains(ctx context.Context, req *mgmt_pb.ListOrgDomains
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListOrgDomainsResponse{
|
||||
Result: org_grpc.DomainsToPb(domains.Domains),
|
||||
Details: object.ToListDetails(
|
||||
domains.Count,
|
||||
domains.Sequence,
|
||||
domains.Timestamp,
|
||||
),
|
||||
Result: org_grpc.DomainsToPb(domains.Domains),
|
||||
Details: object.ToListDetails(domains.Count, domains.Sequence, domains.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -233,12 +229,8 @@ func (s *Server) ListOrgMembers(ctx context.Context, req *mgmt_pb.ListOrgMembers
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListOrgMembersResponse{
|
||||
Result: member_grpc.MembersToPb(s.assetAPIPrefix(ctx), members.Members),
|
||||
Details: object.ToListDetails(
|
||||
members.Count,
|
||||
members.Sequence,
|
||||
members.Timestamp,
|
||||
),
|
||||
Result: member_grpc.MembersToPb(s.assetAPIPrefix(ctx), members.Members),
|
||||
Details: object.ToListDetails(members.Count, members.Sequence, members.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
"github.com/zitadel/zitadel/internal/api/grpc/user"
|
||||
"github.com/zitadel/zitadel/internal/domain"
|
||||
"github.com/zitadel/zitadel/internal/query"
|
||||
|
||||
mgmt_pb "github.com/zitadel/zitadel/pkg/grpc/management"
|
||||
)
|
||||
|
||||
|
@ -50,12 +50,8 @@ func (s *Server) ListProjects(ctx context.Context, req *mgmt_pb.ListProjectsRequ
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListProjectsResponse{
|
||||
Result: project_grpc.ProjectViewsToPb(projects.Projects),
|
||||
Details: object_grpc.ToListDetails(
|
||||
projects.Count,
|
||||
projects.Sequence,
|
||||
projects.Timestamp,
|
||||
),
|
||||
Result: project_grpc.ProjectViewsToPb(projects.Projects),
|
||||
Details: object_grpc.ToListDetails(projects.Count, projects.Sequence, projects.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -77,12 +73,8 @@ func (s *Server) ListGrantedProjects(ctx context.Context, req *mgmt_pb.ListGrant
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListGrantedProjectsResponse{
|
||||
Result: project_grpc.GrantedProjectViewsToPb(projects.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(
|
||||
projects.Count,
|
||||
projects.Sequence,
|
||||
projects.Timestamp,
|
||||
),
|
||||
Result: project_grpc.GrantedProjectViewsToPb(projects.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(projects.Count, projects.Sequence, projects.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -100,12 +92,8 @@ func (s *Server) ListGrantedProjectRoles(ctx context.Context, req *mgmt_pb.ListG
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListGrantedProjectRolesResponse{
|
||||
Result: project_grpc.RoleViewsToPb(roles.ProjectRoles),
|
||||
Details: object_grpc.ToListDetails(
|
||||
roles.Count,
|
||||
roles.Sequence,
|
||||
roles.Timestamp,
|
||||
),
|
||||
Result: project_grpc.RoleViewsToPb(roles.ProjectRoles),
|
||||
Details: object_grpc.ToListDetails(roles.Count, roles.Sequence, roles.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -127,12 +115,8 @@ func (s *Server) AddProject(ctx context.Context, req *mgmt_pb.AddProjectRequest)
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.AddProjectResponse{
|
||||
Id: project.AggregateID,
|
||||
Details: object_grpc.AddToDetailsPb(
|
||||
project.Sequence,
|
||||
project.ChangeDate,
|
||||
project.ResourceOwner,
|
||||
),
|
||||
Id: project.AggregateID,
|
||||
Details: object_grpc.AddToDetailsPb(project.Sequence, project.ChangeDate, project.ResourceOwner),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -208,12 +192,8 @@ func (s *Server) ListProjectRoles(ctx context.Context, req *mgmt_pb.ListProjectR
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListProjectRolesResponse{
|
||||
Result: project_grpc.RoleViewsToPb(roles.ProjectRoles),
|
||||
Details: object_grpc.ToListDetails(
|
||||
roles.Count,
|
||||
roles.Sequence,
|
||||
roles.Timestamp,
|
||||
),
|
||||
Result: project_grpc.RoleViewsToPb(roles.ProjectRoles),
|
||||
Details: object_grpc.ToListDetails(roles.Count, roles.Sequence, roles.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -302,12 +282,8 @@ func (s *Server) ListProjectMembers(ctx context.Context, req *mgmt_pb.ListProjec
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListProjectMembersResponse{
|
||||
Result: member_grpc.MembersToPb(s.assetAPIPrefix(ctx), members.Members),
|
||||
Details: object_grpc.ToListDetails(
|
||||
members.Count,
|
||||
members.Sequence,
|
||||
members.Timestamp,
|
||||
),
|
||||
Result: member_grpc.MembersToPb(s.assetAPIPrefix(ctx), members.Members),
|
||||
Details: object_grpc.ToListDetails(members.Count, members.Sequence, members.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -317,11 +293,7 @@ func (s *Server) AddProjectMember(ctx context.Context, req *mgmt_pb.AddProjectMe
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.AddProjectMemberResponse{
|
||||
Details: object_grpc.AddToDetailsPb(
|
||||
member.Sequence,
|
||||
member.ChangeDate,
|
||||
member.ResourceOwner,
|
||||
),
|
||||
Details: object_grpc.AddToDetailsPb(member.Sequence, member.ChangeDate, member.ResourceOwner),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -33,12 +33,8 @@ func (s *Server) ListApps(ctx context.Context, req *mgmt_pb.ListAppsRequest) (*m
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListAppsResponse{
|
||||
Result: project_grpc.AppsToPb(apps.Apps),
|
||||
Details: object_grpc.ToListDetails(
|
||||
apps.Count,
|
||||
apps.Sequence,
|
||||
apps.Timestamp,
|
||||
),
|
||||
Result: project_grpc.AppsToPb(apps.Apps),
|
||||
Details: object_grpc.ToListDetails(apps.Count, apps.Sequence, apps.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -227,12 +223,8 @@ func (s *Server) ListAppKeys(ctx context.Context, req *mgmt_pb.ListAppKeysReques
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListAppKeysResponse{
|
||||
Result: authn_grpc.KeysToPb(keys.AuthNKeys),
|
||||
Details: object_grpc.ToListDetails(
|
||||
keys.Count,
|
||||
keys.Sequence,
|
||||
keys.Timestamp,
|
||||
),
|
||||
Result: authn_grpc.KeysToPb(keys.AuthNKeys),
|
||||
Details: object_grpc.ToListDetails(keys.Count, keys.Sequence, keys.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -36,12 +36,8 @@ func (s *Server) ListProjectGrants(ctx context.Context, req *mgmt_pb.ListProject
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListProjectGrantsResponse{
|
||||
Result: proj_grpc.GrantedProjectViewsToPb(grants.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(
|
||||
grants.Count,
|
||||
grants.Sequence,
|
||||
grants.Timestamp,
|
||||
),
|
||||
Result: proj_grpc.GrantedProjectViewsToPb(grants.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(grants.Count, grants.Sequence, grants.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -63,12 +59,8 @@ func (s *Server) ListAllProjectGrants(ctx context.Context, req *mgmt_pb.ListAllP
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListAllProjectGrantsResponse{
|
||||
Result: proj_grpc.GrantedProjectViewsToPb(grants.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(
|
||||
grants.Count,
|
||||
grants.Sequence,
|
||||
grants.Timestamp,
|
||||
),
|
||||
Result: proj_grpc.GrantedProjectViewsToPb(grants.ProjectGrants),
|
||||
Details: object_grpc.ToListDetails(grants.Count, grants.Sequence, grants.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -177,12 +169,8 @@ func (s *Server) ListProjectGrantMembers(ctx context.Context, req *mgmt_pb.ListP
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListProjectGrantMembersResponse{
|
||||
Result: member_grpc.MembersToPb(s.assetAPIPrefix(ctx), response.Members),
|
||||
Details: object_grpc.ToListDetails(
|
||||
response.Count,
|
||||
response.Sequence,
|
||||
response.Timestamp,
|
||||
),
|
||||
Result: member_grpc.MembersToPb(s.assetAPIPrefix(ctx), response.Members),
|
||||
Details: object_grpc.ToListDetails(response.Count, response.Sequence, response.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -68,12 +68,8 @@ func (s *Server) ListUsers(ctx context.Context, req *mgmt_pb.ListUsersRequest) (
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListUsersResponse{
|
||||
Result: user_grpc.UsersToPb(res.Users, s.assetAPIPrefix(ctx)),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
res.Count,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: user_grpc.UsersToPb(res.Users, s.assetAPIPrefix(ctx)),
|
||||
Details: obj_grpc.ToListDetails(res.Count, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -120,12 +116,8 @@ func (s *Server) ListUserMetadata(ctx context.Context, req *mgmt_pb.ListUserMeta
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListUserMetadataResponse{
|
||||
Result: metadata.MetadataListToPb(res.Metadata),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
res.Count,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: metadata.MetadataListToPb(res.Metadata),
|
||||
Details: obj_grpc.ToListDetails(res.Count, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -731,12 +723,8 @@ func (s *Server) ListMachineKeys(ctx context.Context, req *mgmt_pb.ListMachineKe
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListMachineKeysResponse{
|
||||
Result: authn.KeysToPb(result.AuthNKeys),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
result.Count,
|
||||
result.Sequence,
|
||||
result.Timestamp,
|
||||
),
|
||||
Result: authn.KeysToPb(result.AuthNKeys),
|
||||
Details: obj_grpc.ToListDetails(result.Count, result.Sequence, result.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -798,12 +786,8 @@ func (s *Server) ListPersonalAccessTokens(ctx context.Context, req *mgmt_pb.List
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListPersonalAccessTokensResponse{
|
||||
Result: user_grpc.PersonalAccessTokensToPb(result.PersonalAccessTokens),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
result.Count,
|
||||
result.Sequence,
|
||||
result.Timestamp,
|
||||
),
|
||||
Result: user_grpc.PersonalAccessTokensToPb(result.PersonalAccessTokens),
|
||||
Details: obj_grpc.ToListDetails(result.Count, result.Sequence, result.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -848,12 +832,8 @@ func (s *Server) ListHumanLinkedIDPs(ctx context.Context, req *mgmt_pb.ListHuman
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListHumanLinkedIDPsResponse{
|
||||
Result: idp_grpc.IDPUserLinksToPb(res.Links),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
res.Count,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: idp_grpc.IDPUserLinksToPb(res.Links),
|
||||
Details: obj_grpc.ToListDetails(res.Count, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
func (s *Server) RemoveHumanLinkedIDP(ctx context.Context, req *mgmt_pb.RemoveHumanLinkedIDPRequest) (*mgmt_pb.RemoveHumanLinkedIDPResponse, error) {
|
||||
@ -876,11 +856,7 @@ func (s *Server) ListUserMemberships(ctx context.Context, req *mgmt_pb.ListUserM
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListUserMembershipsResponse{
|
||||
Result: user_grpc.MembershipsToMembershipsPb(response.Memberships),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
response.Count,
|
||||
response.Sequence,
|
||||
response.Timestamp,
|
||||
),
|
||||
Result: user_grpc.MembershipsToMembershipsPb(response.Memberships),
|
||||
Details: obj_grpc.ToListDetails(response.Count, response.Sequence, response.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
@ -38,12 +38,8 @@ func (s *Server) ListUserGrants(ctx context.Context, req *mgmt_pb.ListUserGrantR
|
||||
return nil, err
|
||||
}
|
||||
return &mgmt_pb.ListUserGrantResponse{
|
||||
Result: user.UserGrantsToPb(s.assetAPIPrefix(ctx), res.UserGrants),
|
||||
Details: obj_grpc.ToListDetails(
|
||||
res.Count,
|
||||
res.Sequence,
|
||||
res.Timestamp,
|
||||
),
|
||||
Result: user.UserGrantsToPb(s.assetAPIPrefix(ctx), res.UserGrants),
|
||||
Details: obj_grpc.ToListDetails(res.Count, res.Sequence, res.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -69,11 +69,15 @@ func ToListDetails(
|
||||
processedSequence uint64,
|
||||
viewTimestamp time.Time,
|
||||
) *object_pb.ListDetails {
|
||||
return &object_pb.ListDetails{
|
||||
details := &object_pb.ListDetails{
|
||||
TotalResult: totalResult,
|
||||
ProcessedSequence: processedSequence,
|
||||
ViewTimestamp: timestamppb.New(viewTimestamp),
|
||||
}
|
||||
if !viewTimestamp.IsZero() {
|
||||
details.ViewTimestamp = timestamppb.New(viewTimestamp)
|
||||
}
|
||||
|
||||
return details
|
||||
}
|
||||
|
||||
func TextMethodToModel(method object_pb.TextQueryMethod) domain.SearchMethod {
|
||||
|
@ -47,17 +47,15 @@ func (s *Server) AddInstance(ctx context.Context, req *system_pb.AddInstanceRequ
|
||||
}
|
||||
return &system_pb.AddInstanceResponse{
|
||||
InstanceId: id,
|
||||
Details: object.AddToDetailsPb(
|
||||
details.Sequence,
|
||||
details.EventDate,
|
||||
details.ResourceOwner,
|
||||
),
|
||||
Details: object.AddToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
||||
}, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *Server) ExistsDomain(ctx context.Context, req *system_pb.ExistsDomainRequest) (*system_pb.ExistsDomainResponse, error) {
|
||||
domainQuery, err := query.NewInstanceDomainDomainSearchQuery(query.TextEqualsIgnoreCase, req.Domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
query := &query.InstanceDomainSearchQueries{
|
||||
SearchRequest: query.SearchRequest{
|
||||
@ -90,12 +88,8 @@ func (s *Server) ListDomains(ctx context.Context, req *system_pb.ListDomainsRequ
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.ListDomainsResponse{
|
||||
Result: instance_grpc.DomainsToPb(domains.Domains),
|
||||
Details: object.ToListDetails(
|
||||
domains.Count,
|
||||
domains.Sequence,
|
||||
domains.Timestamp,
|
||||
),
|
||||
Result: instance_grpc.DomainsToPb(domains.Domains),
|
||||
Details: object.ToListDetails(domains.Count, domains.Sequence, domains.Timestamp),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -111,11 +105,7 @@ func (s *Server) AddDomain(ctx context.Context, req *system_pb.AddDomainRequest)
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.AddDomainResponse{
|
||||
Details: object.AddToDetailsPb(
|
||||
details.Sequence,
|
||||
details.EventDate,
|
||||
details.ResourceOwner,
|
||||
),
|
||||
Details: object.AddToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -126,11 +116,7 @@ func (s *Server) RemoveDomain(ctx context.Context, req *system_pb.RemoveDomainRe
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.RemoveDomainResponse{
|
||||
Details: object.ChangeToDetailsPb(
|
||||
details.Sequence,
|
||||
details.EventDate,
|
||||
details.ResourceOwner,
|
||||
),
|
||||
Details: object.ChangeToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@ -141,10 +127,6 @@ func (s *Server) SetPrimaryDomain(ctx context.Context, req *system_pb.SetPrimary
|
||||
return nil, err
|
||||
}
|
||||
return &system_pb.SetPrimaryDomainResponse{
|
||||
Details: object.ChangeToDetailsPb(
|
||||
details.Sequence,
|
||||
details.EventDate,
|
||||
details.ResourceOwner,
|
||||
),
|
||||
Details: object.ChangeToDetailsPb(details.Sequence, details.EventDate, details.ResourceOwner),
|
||||
}, nil
|
||||
}
|
||||
|
@ -201,10 +201,7 @@ func prepareLatestSequence() (sq.SelectBuilder, func(*sql.Row) (*LatestSequence,
|
||||
&seq.Sequence,
|
||||
&seq.Timestamp,
|
||||
)
|
||||
if err != nil {
|
||||
if errs.Is(err, sql.ErrNoRows) {
|
||||
return nil, errors.ThrowNotFound(err, "QUERY-gmd9o", "Errors.CurrentSequence.NotFound")
|
||||
}
|
||||
if err != nil && !errs.Is(err, sql.ErrNoRows) {
|
||||
return nil, errors.ThrowInternal(err, "QUERY-aAZ1D", "Errors.Internal")
|
||||
}
|
||||
return seq, nil
|
||||
|
Loading…
Reference in New Issue
Block a user