feat(evidence): project skill evidence from confirmed assessments
This commit is contained in:
1 parent
4761508f13
commit
c2a8d17195
94 files changed
+10077
-151
No files matched your search
@@ -29,6 +29,7 @@ type Handler struct {
|
||||
assessment *AssessmentHandler
|
||||
assessmentSignals *AssessmentSignalHandler
|
||||
privacy *PrivacyHandler
|
||||
evidence *EvidenceHandler
|
||||
problems *problem.Responder
|
||||
}
|
||||
|
||||
@@ -92,6 +93,12 @@ func WithPrivacy(privacy *PrivacyHandler) HandlerOption {
|
||||
return func(handler *Handler) { handler.privacy = privacy }
|
||||
}
|
||||
|
||||
// WithEvidence serves the skill evidence of a candidate and its permitted
|
||||
// organization projection.
|
||||
func WithEvidence(evidence *EvidenceHandler) HandlerOption {
|
||||
return func(handler *Handler) { handler.evidence = evidence }
|
||||
}
|
||||
|
||||
func NewHandler(health *HealthHandler, problems *problem.Responder, options ...HandlerOption) *Handler {
|
||||
handler := &Handler{health: health, problems: problems}
|
||||
for _, option := range options {
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/adapter/primary/http/api"
|
||||
"lincodex/backend/internal/adapter/primary/http/problem"
|
||||
"lincodex/backend/internal/domain"
|
||||
"lincodex/backend/internal/port/outbound"
|
||||
"lincodex/backend/internal/usecase/candidateview"
|
||||
"lincodex/backend/internal/usecase/evidence"
|
||||
)
|
||||
|
||||
// EvidenceOperations reads the skill evidence projection.
|
||||
type EvidenceOperations interface {
|
||||
ListMine(ctx context.Context, query outbound.EvidenceListQuery) (outbound.EvidenceFactPage, error)
|
||||
ListForOrganization(ctx context.Context, actorID, organizationID uuid.UUID, handle string) ([]domain.EvidenceOrganizationFact, error)
|
||||
}
|
||||
|
||||
// EvidenceHandler binds the evidence read use cases to the v1 API.
|
||||
type EvidenceHandler struct {
|
||||
operations EvidenceOperations
|
||||
}
|
||||
|
||||
func NewEvidenceHandler(operations EvidenceOperations) *EvidenceHandler {
|
||||
if operations == nil {
|
||||
panic("v1.NewEvidenceHandler - operations must not be nil")
|
||||
}
|
||||
return &EvidenceHandler{operations: operations}
|
||||
}
|
||||
|
||||
func (handler *Handler) ListMyEvidence(ctx context.Context, params api.ListMyEvidenceParams) (api.ListMyEvidenceRes, error) {
|
||||
if handler.evidence == nil {
|
||||
return handler.UnimplementedHandler.ListMyEvidence(ctx, params)
|
||||
}
|
||||
return handler.evidence.ListMyEvidence(ctx, params)
|
||||
}
|
||||
|
||||
func (handler *Handler) GetOrganizationCandidateEvidence(
|
||||
ctx context.Context,
|
||||
params api.GetOrganizationCandidateEvidenceParams,
|
||||
) (api.GetOrganizationCandidateEvidenceRes, error) {
|
||||
if handler.evidence == nil {
|
||||
return handler.UnimplementedHandler.GetOrganizationCandidateEvidence(ctx, params)
|
||||
}
|
||||
return handler.evidence.GetOrganizationCandidateEvidence(ctx, params)
|
||||
}
|
||||
|
||||
func (handler *EvidenceHandler) ListMyEvidence(ctx context.Context, params api.ListMyEvidenceParams) (api.ListMyEvidenceRes, error) {
|
||||
const location = "EvidenceHandler.ListMyEvidence"
|
||||
principal, ok := PrincipalFromContext(ctx)
|
||||
if !ok {
|
||||
return (*api.ListMyEvidenceUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
|
||||
}
|
||||
limit, cursor, pointer := privacyPageParams(params.Limit, params.Cursor, principal.UserID, privacyCursorEvidence)
|
||||
if pointer != "" {
|
||||
return (*api.ListMyEvidenceBadRequest)(&problem.InvalidField(ctx, api.ProblemFieldLocationQuery, "/"+pointer).Response), nil
|
||||
}
|
||||
query := outbound.EvidenceListQuery{CandidateID: principal.UserID, Limit: limit}
|
||||
if cursor != nil {
|
||||
query.After = &outbound.EvidencePosition{OccurredAt: cursor.at, ID: cursor.id}
|
||||
}
|
||||
page, err := handler.operations.ListMine(ctx, query)
|
||||
if err != nil {
|
||||
if errors.Is(err, evidence.ErrForbidden) {
|
||||
return (*api.ListMyEvidenceForbidden)(&problem.New(ctx, api.ProblemCodeForbidden).Response), nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
items := make([]api.EvidenceFact, 0, len(page.Items))
|
||||
for _, fact := range page.Items {
|
||||
items = append(items, evidenceFactResponse(fact.Snapshot()))
|
||||
}
|
||||
next, err := privacyNextCursor(page.HasMore, len(page.Items), func() (string, error) {
|
||||
last := outbound.EvidencePositionOf(page.Items[len(page.Items)-1])
|
||||
return encodePrivacyCursor(principal.UserID, privacyCursorEvidence, last.OccurredAt, last.ID)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s - encode cursor: %w", location, err)
|
||||
}
|
||||
return &api.EvidenceFactListHeaders{
|
||||
CacheControl: api.CacheControlNoStoreNoStore,
|
||||
Response: api.EvidenceFactList{Items: items, Page: api.PageInfo{HasMore: page.HasMore, NextCursor: next}},
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (handler *EvidenceHandler) GetOrganizationCandidateEvidence(
|
||||
ctx context.Context,
|
||||
params api.GetOrganizationCandidateEvidenceParams,
|
||||
) (api.GetOrganizationCandidateEvidenceRes, error) {
|
||||
principal, ok := PrincipalFromContext(ctx)
|
||||
if !ok {
|
||||
return (*api.GetOrganizationCandidateEvidenceUnauthorized)(&problem.New(ctx, api.ProblemCodeUnauthenticated).Response), nil
|
||||
}
|
||||
facts, err := handler.operations.ListForOrganization(ctx, principal.UserID, params.OrgID, string(params.CandidateHandle))
|
||||
if err != nil {
|
||||
switch {
|
||||
case errors.Is(err, candidateview.ErrForbidden):
|
||||
return (*api.GetOrganizationCandidateEvidenceForbidden)(&problem.New(ctx, api.ProblemCodeForbidden).Response), nil
|
||||
case errors.Is(err, candidateview.ErrCandidateCardNotFound), errors.Is(err, outbound.ErrOrganizationNotFound):
|
||||
return (*api.GetOrganizationCandidateEvidenceNotFound)(&problem.New(ctx, api.ProblemCodeNotFound).Response), nil
|
||||
case errors.Is(err, candidateview.ErrInvalidCandidateHandle):
|
||||
return (*api.GetOrganizationCandidateEvidenceBadRequest)(&problem.InvalidField(ctx, api.ProblemFieldLocationPath, "/candidate_handle").Response), nil
|
||||
}
|
||||
if limited, ok := candidateViewRateLimited(ctx, err); ok {
|
||||
return limited, nil
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
evidence := organizationEvidenceResponse(facts)
|
||||
return &api.OrganizationEvidenceHeaders{
|
||||
CacheControl: api.CacheControlNoStoreNoStore,
|
||||
Response: evidence,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func evidenceFactResponse(fact domain.EvidenceFactSnapshot) api.EvidenceFact {
|
||||
return api.EvidenceFact{
|
||||
ID: fact.ID, Kind: api.EvidenceKind(fact.Kind),
|
||||
Source: api.EvidenceSource{
|
||||
Type: api.EvidenceSourceType(fact.SourceType), EventID: fact.EventID, ResultID: fact.ResultID,
|
||||
},
|
||||
Skills: evidenceSkillsResponse(fact.Skills),
|
||||
Result: evidenceResultResponse(fact.Result),
|
||||
Attribution: api.EvidenceAttribution(fact.Attribution), Trust: api.EvidenceTrustLevel(fact.Trust),
|
||||
OccurredAt: api.Timestamp(fact.OccurredAt), Visibility: api.EvidenceVisibility(fact.Visibility),
|
||||
}
|
||||
}
|
||||
|
||||
// organizationEvidenceResponse maps the allowlisted facts that an
|
||||
// organization, or the preview of the candidate, reads.
|
||||
func organizationEvidenceResponse(facts []domain.EvidenceOrganizationFact) api.OrganizationEvidence {
|
||||
items := make([]api.OrganizationEvidenceFact, 0, len(facts))
|
||||
for _, fact := range facts {
|
||||
input := fact.Input()
|
||||
items = append(items, api.OrganizationEvidenceFact{
|
||||
Skill: api.EvidenceSkillCode(input.Skill), Grade: api.GradeCode(input.Grade),
|
||||
Trust: api.EvidenceTrustLevel(input.Trust), Basis: api.EvidenceBasis(input.Basis),
|
||||
CalibrationStatus: api.EvidenceCalibrationStatus(input.CalibrationStatus), ObservedYear: input.ObservedYear,
|
||||
})
|
||||
}
|
||||
return api.OrganizationEvidence{Items: items}
|
||||
}
|
||||
|
||||
func evidenceSkillsResponse(skills []domain.EvidenceSkillCode) []api.EvidenceSkillCode {
|
||||
response := make([]api.EvidenceSkillCode, 0, len(skills))
|
||||
for _, skill := range skills {
|
||||
response = append(response, api.EvidenceSkillCode(skill))
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
func evidenceResultResponse(result domain.EvidenceResult) api.EvidenceResult {
|
||||
return api.EvidenceResult{
|
||||
Grade: api.GradeCode(result.Grade), Basis: api.EvidenceBasis(result.Basis),
|
||||
CalibrationStatus: api.EvidenceCalibrationStatus(result.CalibrationStatus),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,225 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"lincodex/backend/internal/adapter/primary/http/api"
|
||||
"lincodex/backend/internal/domain"
|
||||
"lincodex/backend/internal/port/outbound"
|
||||
"lincodex/backend/internal/usecase/candidateview"
|
||||
"lincodex/backend/internal/usecase/evidence"
|
||||
)
|
||||
|
||||
type evidenceOperationsStub struct {
|
||||
page outbound.EvidenceFactPage
|
||||
facts []domain.EvidenceOrganizationFact
|
||||
err error
|
||||
query outbound.EvidenceListQuery
|
||||
actorID uuid.UUID
|
||||
orgID uuid.UUID
|
||||
handle string
|
||||
listCalls int
|
||||
}
|
||||
|
||||
func (stub *evidenceOperationsStub) ListMine(_ context.Context, query outbound.EvidenceListQuery) (outbound.EvidenceFactPage, error) {
|
||||
stub.query = query
|
||||
return stub.page, stub.err
|
||||
}
|
||||
|
||||
func (stub *evidenceOperationsStub) ListForOrganization(_ context.Context, actorID, organizationID uuid.UUID, handle string) ([]domain.EvidenceOrganizationFact, error) {
|
||||
stub.listCalls++
|
||||
stub.actorID, stub.orgID, stub.handle = actorID, organizationID, handle
|
||||
return stub.facts, stub.err
|
||||
}
|
||||
|
||||
func evidenceTestFact(t *testing.T, candidateID uuid.UUID, at time.Time) domain.EvidenceFact {
|
||||
t.Helper()
|
||||
attempt := uuid.New()
|
||||
fact, err := domain.RestoreEvidenceFact(domain.EvidenceFactSnapshot{
|
||||
ID: uuid.New(), CandidateID: candidateID, Kind: domain.EvidenceKindMeasurement,
|
||||
SourceType: domain.EvidenceSourceAssessmentResult, EventID: attempt, ResultID: attempt,
|
||||
Skills: []domain.EvidenceSkillCode{"go", "backend"},
|
||||
Result: domain.EvidenceResult{
|
||||
Grade: domain.GradeJunior, Basis: domain.AssessmentCategorySourceSyntheticDemo,
|
||||
CalibrationStatus: domain.AssessmentCategoryCalibrationUncalibrated,
|
||||
},
|
||||
Attribution: domain.EvidenceAttributionPersonal, Trust: domain.EvidenceTrustOnlineUnconfirmed,
|
||||
OccurredAt: at, Visibility: domain.EvidenceVisibilityVisible,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("RestoreEvidenceFact() error = %v", err)
|
||||
}
|
||||
return fact
|
||||
}
|
||||
|
||||
func TestListMyEvidenceMapsFactsAndPagesWithAnOwnerBoundCursor(t *testing.T) {
|
||||
userID := uuid.New()
|
||||
at := time.Date(2026, 10, 8, 10, 15, 0, 0, time.UTC)
|
||||
stub := &evidenceOperationsStub{page: outbound.EvidenceFactPage{
|
||||
Items: []domain.EvidenceFact{evidenceTestFact(t, userID, at)},
|
||||
HasMore: true,
|
||||
}}
|
||||
handler := NewEvidenceHandler(stub)
|
||||
ctx := privacyHTTPContext(userID, "")
|
||||
|
||||
response, err := handler.ListMyEvidence(ctx, api.ListMyEvidenceParams{Limit: api.NewOptInt32(1)})
|
||||
if err != nil {
|
||||
t.Fatalf("ListMyEvidence() error = %v", err)
|
||||
}
|
||||
page, ok := response.(*api.EvidenceFactListHeaders)
|
||||
if !ok || page.CacheControl != api.CacheControlNoStoreNoStore || len(page.Response.Items) != 1 {
|
||||
t.Fatalf("ListMyEvidence() = %#v, want a no-store page of one fact", response)
|
||||
}
|
||||
item := page.Response.Items[0]
|
||||
if item.Trust != 1 || item.Kind != api.EvidenceKindMeasurement || item.Source.EventID != item.Source.ResultID ||
|
||||
len(item.Skills) != 2 || item.Skills[0] != api.EvidenceSkillCodeBackend || item.Result.Grade != api.GradeCodeJunior ||
|
||||
item.Visibility != api.EvidenceVisibilityVisible || !time.Time(item.OccurredAt).Equal(at) {
|
||||
t.Fatalf("fact mapping = %+v", item)
|
||||
}
|
||||
if stub.query.CandidateID != userID || stub.query.Limit != 1 || stub.query.After != nil {
|
||||
t.Fatalf("query = %+v, want the session owner and the first page", stub.query)
|
||||
}
|
||||
cursor, set := page.Response.Page.NextCursor.Get()
|
||||
if !page.Response.Page.HasMore || !set || cursor == "" {
|
||||
t.Fatalf("page info = %+v, want a next cursor", page.Response.Page)
|
||||
}
|
||||
|
||||
// The cursor continues the same owner's list at the last fact of the page.
|
||||
if _, err := handler.ListMyEvidence(ctx, api.ListMyEvidenceParams{Cursor: api.NewOptString(cursor)}); err != nil {
|
||||
t.Fatalf("ListMyEvidence(cursor) error = %v", err)
|
||||
}
|
||||
if stub.query.After == nil || stub.query.After.ID != stub.page.Items[0].Snapshot().ID || !stub.query.After.OccurredAt.Equal(at) {
|
||||
t.Fatalf("continuation = %+v, want the last fact of the previous page", stub.query.After)
|
||||
}
|
||||
|
||||
// A cursor of another candidate, a cursor of another list, and a limit out of range are validation errors.
|
||||
foreign, err := encodePrivacyCursor(uuid.New(), privacyCursorEvidence, at, uuid.New())
|
||||
if err != nil {
|
||||
t.Fatalf("encodePrivacyCursor() error = %v", err)
|
||||
}
|
||||
otherList, err := encodePrivacyCursor(userID, privacyCursorAccess, at, uuid.New())
|
||||
if err != nil {
|
||||
t.Fatalf("encodePrivacyCursor() error = %v", err)
|
||||
}
|
||||
for name, params := range map[string]api.ListMyEvidenceParams{
|
||||
"foreign cursor": {Cursor: api.NewOptString(foreign)},
|
||||
"other list": {Cursor: api.NewOptString(otherList)},
|
||||
"malformed cursor": {Cursor: api.NewOptString("not-a-cursor")},
|
||||
"limit too large": {Limit: api.NewOptInt32(outbound.MaxEvidencePageSize + 1)},
|
||||
} {
|
||||
response, err := handler.ListMyEvidence(ctx, params)
|
||||
if _, bad := response.(*api.ListMyEvidenceBadRequest); err != nil || !bad {
|
||||
t.Errorf("%s = %#v, %v, want 400", name, response, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestListMyEvidenceMapsAccessFailures(t *testing.T) {
|
||||
userID := uuid.New()
|
||||
stub := &evidenceOperationsStub{err: evidence.ErrForbidden}
|
||||
handler := NewEvidenceHandler(stub)
|
||||
response, err := handler.ListMyEvidence(privacyHTTPContext(userID, ""), api.ListMyEvidenceParams{})
|
||||
if _, forbidden := response.(*api.ListMyEvidenceForbidden); err != nil || !forbidden {
|
||||
t.Fatalf("forbidden actor = %#v, %v, want 403", response, err)
|
||||
}
|
||||
unauthenticated, err := handler.ListMyEvidence(context.Background(), api.ListMyEvidenceParams{})
|
||||
if _, ok := unauthenticated.(*api.ListMyEvidenceUnauthorized); err != nil || !ok {
|
||||
t.Fatalf("no principal = %#v, %v, want 401", unauthenticated, err)
|
||||
}
|
||||
stub.err = errors.New("storage failed")
|
||||
if _, err := handler.ListMyEvidence(privacyHTTPContext(userID, ""), api.ListMyEvidenceParams{}); err == nil {
|
||||
t.Fatal("an unexpected failure was swallowed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrganizationEvidenceMapsOnlyTheAllowlistedShape(t *testing.T) {
|
||||
userID, organizationID := uuid.New(), uuid.New()
|
||||
handle := "cv1_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||
fact, err := domain.NewEvidenceOrganizationFact(domain.EvidenceOrganizationFactInput{
|
||||
Skill: "backend", Grade: domain.GradeJunior, Trust: domain.EvidenceTrustOnlineUnconfirmed,
|
||||
Basis: domain.AssessmentCategorySourceSyntheticDemo, CalibrationStatus: domain.AssessmentCategoryCalibrationUncalibrated, ObservedYear: 2026,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("NewEvidenceOrganizationFact() error = %v", err)
|
||||
}
|
||||
stub := &evidenceOperationsStub{facts: []domain.EvidenceOrganizationFact{fact}}
|
||||
handler := NewEvidenceHandler(stub)
|
||||
ctx := privacyHTTPContext(userID, "")
|
||||
params := api.GetOrganizationCandidateEvidenceParams{OrgID: organizationID, CandidateHandle: api.CandidateHandle(handle)}
|
||||
|
||||
response, err := handler.GetOrganizationCandidateEvidence(ctx, params)
|
||||
if err != nil {
|
||||
t.Fatalf("GetOrganizationCandidateEvidence() error = %v", err)
|
||||
}
|
||||
body, ok := response.(*api.OrganizationEvidenceHeaders)
|
||||
if !ok || body.CacheControl != api.CacheControlNoStoreNoStore || len(body.Response.Items) != 1 {
|
||||
t.Fatalf("response = %#v, want a no-store projection of one fact", response)
|
||||
}
|
||||
if stub.actorID != userID || stub.orgID != organizationID || stub.handle != handle {
|
||||
t.Fatalf("scope = actor %s organization %s handle %q", stub.actorID, stub.orgID, stub.handle)
|
||||
}
|
||||
encoded, err := json.Marshal(body.Response)
|
||||
if err != nil {
|
||||
t.Fatalf("encode projection: %v", err)
|
||||
}
|
||||
if want := `{"items":[{"skill":"backend","grade":"junior","trust":1,"basis":"synthetic_demo","calibration_status":"uncalibrated","observed_year":2026}]}`; string(encoded) != want {
|
||||
t.Fatalf("projection = %s, want %s", encoded, want)
|
||||
}
|
||||
for _, private := range []string{userID.String(), "event_id", "result_id", "occurred_at", "observed_month", "answer", "score", "visibility"} {
|
||||
if strings.Contains(string(encoded), private) {
|
||||
t.Fatalf("organization projection exposes %q: %s", private, encoded)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestOrganizationEvidenceMapsCardFailuresWithoutDistinction(t *testing.T) {
|
||||
userID, organizationID := uuid.New(), uuid.New()
|
||||
handle := api.CandidateHandle("cv1_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
|
||||
stub := &evidenceOperationsStub{}
|
||||
handler := NewEvidenceHandler(stub)
|
||||
ctx := privacyHTTPContext(userID, "")
|
||||
params := api.GetOrganizationCandidateEvidenceParams{OrgID: organizationID, CandidateHandle: handle}
|
||||
|
||||
for name, test := range map[string]struct {
|
||||
err error
|
||||
want string
|
||||
}{
|
||||
"candidate account": {candidateview.ErrForbidden, "forbidden"},
|
||||
"hidden or unpublished": {candidateview.ErrCandidateCardNotFound, "not_found"},
|
||||
"no membership": {outbound.ErrOrganizationNotFound, "not_found"},
|
||||
"bad handle": {candidateview.ErrInvalidCandidateHandle, "bad_request"},
|
||||
"quota": {&candidateview.RateLimitedError{RetryAt: time.Now().Add(time.Minute)}, "too_many"},
|
||||
} {
|
||||
stub.err = test.err
|
||||
response, err := handler.GetOrganizationCandidateEvidence(ctx, params)
|
||||
if err != nil {
|
||||
t.Errorf("%s: error = %v", name, err)
|
||||
continue
|
||||
}
|
||||
var got string
|
||||
switch response.(type) {
|
||||
case *api.GetOrganizationCandidateEvidenceForbidden:
|
||||
got = "forbidden"
|
||||
case *api.GetOrganizationCandidateEvidenceNotFound:
|
||||
got = "not_found"
|
||||
case *api.GetOrganizationCandidateEvidenceBadRequest:
|
||||
got = "bad_request"
|
||||
case *api.TooManyRequestsHeaders:
|
||||
got = "too_many"
|
||||
}
|
||||
if got != test.want {
|
||||
t.Errorf("%s = %T, want %s", name, response, test.want)
|
||||
}
|
||||
}
|
||||
stub.err = errors.New("storage failed")
|
||||
if _, err := handler.GetOrganizationCandidateEvidence(ctx, params); err == nil {
|
||||
t.Fatal("an unexpected failure was swallowed")
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,9 @@ const (
|
||||
privacyCursorEvents = 1
|
||||
privacyCursorHidden = 2
|
||||
privacyCursorAccess = 3
|
||||
// privacyCursorEvidence belongs to the skill evidence list, which shares the
|
||||
// owner-bound cursor of the privacy lists.
|
||||
privacyCursorEvidence = 4
|
||||
)
|
||||
|
||||
// CandidateViewOperations serves private previews, owner access history, and
|
||||
@@ -434,7 +437,7 @@ func privacyPageParams(limit api.OptInt32, cursor api.OptString, owner uuid.UUID
|
||||
func encodePrivacyCursor(owner uuid.UUID, kind byte, at time.Time, id uuid.UUID) (string, error) {
|
||||
at = at.UTC()
|
||||
seconds, nanos := at.Unix(), at.Nanosecond()
|
||||
if owner == uuid.Nil || id == uuid.Nil || kind < privacyCursorEvents || kind > privacyCursorAccess || at.IsZero() ||
|
||||
if owner == uuid.Nil || id == uuid.Nil || kind < privacyCursorEvents || kind > privacyCursorEvidence || at.IsZero() ||
|
||||
at.Year() < 1 || at.Year() > 9999 || nanos < 0 || nanos >= 1_000_000_000 || nanos%1_000 != 0 {
|
||||
return "", errors.New("privacy cursor requires an owner and valid page position")
|
||||
}
|
||||
@@ -518,7 +521,13 @@ func cardPreviewResponse(preview candidateview.PreviewResult) api.CardPreview {
|
||||
} else {
|
||||
card.SetTo(anonymousCardResponse(*preview.Card))
|
||||
}
|
||||
return api.CardPreview{State: state, Fields: fields, Card: card, GeneratedAt: api.Timestamp(preview.GeneratedAt)}
|
||||
evidence := api.NilOrganizationEvidence{}
|
||||
if preview.Card == nil {
|
||||
evidence.SetToNull()
|
||||
} else {
|
||||
evidence.SetTo(organizationEvidenceResponse(preview.Evidence))
|
||||
}
|
||||
return api.CardPreview{State: state, Fields: fields, Card: card, Evidence: evidence, GeneratedAt: api.Timestamp(preview.GeneratedAt)}
|
||||
}
|
||||
|
||||
func anonymousCardResponse(view domain.AnonymousCandidateViewDTO) api.AnonymousCardContent {
|
||||
|
||||
Reference in new issue
Block a user