feat(visibility): add the candidate publication, hiding and search status contract
This commit is contained in:
1 parent
4436f626a3
commit
0529601021
87 files changed
+21456
-83
No files matched your search
File diff suppressed because it is too large.
Load diff
@@ -65,10 +65,18 @@ type GetMyAssessmentResultRes interface {
|
||||
getMyAssessmentResultRes()
|
||||
}
|
||||
|
||||
type GetMyCardPreviewRes interface {
|
||||
getMyCardPreviewRes()
|
||||
}
|
||||
|
||||
type GetMyInvitationRes interface {
|
||||
getMyInvitationRes()
|
||||
}
|
||||
|
||||
type GetMyPrivacySettingsRes interface {
|
||||
getMyPrivacySettingsRes()
|
||||
}
|
||||
|
||||
type GetMyProfileRes interface {
|
||||
getMyProfileRes()
|
||||
}
|
||||
@@ -97,10 +105,22 @@ type GetOrganizationRes interface {
|
||||
getOrganizationRes()
|
||||
}
|
||||
|
||||
type HideOrganizationRes interface {
|
||||
hideOrganizationRes()
|
||||
}
|
||||
|
||||
type ListMyCardAccessHistoryRes interface {
|
||||
listMyCardAccessHistoryRes()
|
||||
}
|
||||
|
||||
type ListMyConsentsRes interface {
|
||||
listMyConsentsRes()
|
||||
}
|
||||
|
||||
type ListMyHiddenOrganizationsRes interface {
|
||||
listMyHiddenOrganizationsRes()
|
||||
}
|
||||
|
||||
type ListMyInvitationsRes interface {
|
||||
listMyInvitationsRes()
|
||||
}
|
||||
@@ -109,6 +129,10 @@ type ListMyOrganizationsRes interface {
|
||||
listMyOrganizationsRes()
|
||||
}
|
||||
|
||||
type ListMyPrivacyHistoryRes interface {
|
||||
listMyPrivacyHistoryRes()
|
||||
}
|
||||
|
||||
type ListMySupportCasesRes interface {
|
||||
listMySupportCasesRes()
|
||||
}
|
||||
@@ -153,10 +177,22 @@ type SendOrganizationInvitationRes interface {
|
||||
sendOrganizationInvitationRes()
|
||||
}
|
||||
|
||||
type SetMyPublicationRes interface {
|
||||
setMyPublicationRes()
|
||||
}
|
||||
|
||||
type SetMySearchStatusRes interface {
|
||||
setMySearchStatusRes()
|
||||
}
|
||||
|
||||
type SubmitMyAssessmentAnswerRes interface {
|
||||
submitMyAssessmentAnswerRes()
|
||||
}
|
||||
|
||||
type UnhideOrganizationRes interface {
|
||||
unhideOrganizationRes()
|
||||
}
|
||||
|
||||
type UpdateOrganizationInvitationRes interface {
|
||||
updateOrganizationInvitationRes()
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -23,7 +23,9 @@ const (
|
||||
GetMyAssessmentAttemptOperation OperationName = "GetMyAssessmentAttempt"
|
||||
GetMyAssessmentAvailabilityOperation OperationName = "GetMyAssessmentAvailability"
|
||||
GetMyAssessmentResultOperation OperationName = "GetMyAssessmentResult"
|
||||
GetMyCardPreviewOperation OperationName = "GetMyCardPreview"
|
||||
GetMyInvitationOperation OperationName = "GetMyInvitation"
|
||||
GetMyPrivacySettingsOperation OperationName = "GetMyPrivacySettings"
|
||||
GetMyProfileOperation OperationName = "GetMyProfile"
|
||||
GetMyQuestionnaireOperation OperationName = "GetMyQuestionnaire"
|
||||
GetMySupportCaseOperation OperationName = "GetMySupportCase"
|
||||
@@ -32,9 +34,13 @@ const (
|
||||
GetOrganizationInvitationContactsOperation OperationName = "GetOrganizationInvitationContacts"
|
||||
GetOrganizationNeedOperation OperationName = "GetOrganizationNeed"
|
||||
GetSpecializationCatalogOperation OperationName = "GetSpecializationCatalog"
|
||||
HideOrganizationOperation OperationName = "HideOrganization"
|
||||
ListMyCardAccessHistoryOperation OperationName = "ListMyCardAccessHistory"
|
||||
ListMyConsentsOperation OperationName = "ListMyConsents"
|
||||
ListMyHiddenOrganizationsOperation OperationName = "ListMyHiddenOrganizations"
|
||||
ListMyInvitationsOperation OperationName = "ListMyInvitations"
|
||||
ListMyOrganizationsOperation OperationName = "ListMyOrganizations"
|
||||
ListMyPrivacyHistoryOperation OperationName = "ListMyPrivacyHistory"
|
||||
ListMySupportCasesOperation OperationName = "ListMySupportCases"
|
||||
ListOrganizationInvitationsOperation OperationName = "ListOrganizationInvitations"
|
||||
ListOrganizationNeedsOperation OperationName = "ListOrganizationNeeds"
|
||||
@@ -46,7 +52,10 @@ const (
|
||||
SaveMyProfileOperation OperationName = "SaveMyProfile"
|
||||
SaveMyQuestionnaireOperation OperationName = "SaveMyQuestionnaire"
|
||||
SendOrganizationInvitationOperation OperationName = "SendOrganizationInvitation"
|
||||
SetMyPublicationOperation OperationName = "SetMyPublication"
|
||||
SetMySearchStatusOperation OperationName = "SetMySearchStatus"
|
||||
SubmitMyAssessmentAnswerOperation OperationName = "SubmitMyAssessmentAnswer"
|
||||
UnhideOrganizationOperation OperationName = "UnhideOrganization"
|
||||
UpdateOrganizationOperation OperationName = "UpdateOrganization"
|
||||
UpdateOrganizationInvitationOperation OperationName = "UpdateOrganizationInvitation"
|
||||
UpdateOrganizationNeedOperation OperationName = "UpdateOrganizationNeed"
|
||||
|
||||
@@ -1982,6 +1982,252 @@ func decodeGetOrganizationNeedParams(args [2]string, argsEscaped bool, r *http.R
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// HideOrganizationParams is parameters of HideOrganization operation.
|
||||
type HideOrganizationParams struct {
|
||||
// Identifier of the organization that the current candidate hides or stops hiding the profile from. It
|
||||
// names the target of a candidate's own setting and grants the candidate nothing about the
|
||||
// organization. Hiding answers the same 404 not_found for an organization that does not exist and for
|
||||
// one that the candidate cannot see, so organizations cannot be enumerated; lifting the hiding answers
|
||||
// 204 for any well-formed identifier.
|
||||
OrgID uuid.UUID
|
||||
}
|
||||
|
||||
func unpackHideOrganizationParams(packed middleware.Parameters) (params HideOrganizationParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "org_id",
|
||||
In: "path",
|
||||
}
|
||||
params.OrgID = packed[key].(uuid.UUID)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeHideOrganizationParams(args [1]string, argsEscaped bool, r *http.Request) (params HideOrganizationParams, _ error) {
|
||||
// Decode path: org_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "org_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.OrgID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "org_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListMyCardAccessHistoryParams is parameters of ListMyCardAccessHistory operation.
|
||||
type ListMyCardAccessHistoryParams struct {
|
||||
// Maximum number of items in the page. The server may return fewer items even when more remain; use
|
||||
// `page.has_more` to detect the end.
|
||||
Limit OptInt32 `json:",omitempty,omitzero"`
|
||||
// Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the
|
||||
// first page. A malformed or foreign cursor returns 400 with code validation_failed.
|
||||
Cursor OptString `json:",omitempty,omitzero"`
|
||||
}
|
||||
|
||||
func unpackListMyCardAccessHistoryParams(packed middleware.Parameters) (params ListMyCardAccessHistoryParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "limit",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Limit = v.(OptInt32)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "cursor",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Cursor = v.(OptString)
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeListMyCardAccessHistoryParams(args [0]string, argsEscaped bool, r *http.Request) (params ListMyCardAccessHistoryParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Set default value for query: limit.
|
||||
{
|
||||
val := int32(20)
|
||||
params.Limit.SetTo(val)
|
||||
}
|
||||
// Decode query: limit.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "limit",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotLimitVal int32
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt32(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotLimitVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Limit.SetTo(paramsDotLimitVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Limit.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Int{
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 100,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
MultipleOf: 0,
|
||||
Pattern: nil,
|
||||
}).Validate(int64(value)); err != nil {
|
||||
return errors.Wrap(err, "int")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "limit",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: cursor.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "cursor",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotCursorVal string
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotCursorVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Cursor.SetTo(paramsDotCursorVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Cursor.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 512,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9_-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "cursor",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListMyConsentsParams is parameters of ListMyConsents operation.
|
||||
type ListMyConsentsParams struct {
|
||||
// Lists only the records in this state; omit it for the whole history.
|
||||
@@ -2225,6 +2471,182 @@ func decodeListMyConsentsParams(args [0]string, argsEscaped bool, r *http.Reques
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListMyHiddenOrganizationsParams is parameters of ListMyHiddenOrganizations operation.
|
||||
type ListMyHiddenOrganizationsParams struct {
|
||||
// Maximum number of items in the page. The server may return fewer items even when more remain; use
|
||||
// `page.has_more` to detect the end.
|
||||
Limit OptInt32 `json:",omitempty,omitzero"`
|
||||
// Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the
|
||||
// first page. A malformed or foreign cursor returns 400 with code validation_failed.
|
||||
Cursor OptString `json:",omitempty,omitzero"`
|
||||
}
|
||||
|
||||
func unpackListMyHiddenOrganizationsParams(packed middleware.Parameters) (params ListMyHiddenOrganizationsParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "limit",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Limit = v.(OptInt32)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "cursor",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Cursor = v.(OptString)
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeListMyHiddenOrganizationsParams(args [0]string, argsEscaped bool, r *http.Request) (params ListMyHiddenOrganizationsParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Set default value for query: limit.
|
||||
{
|
||||
val := int32(20)
|
||||
params.Limit.SetTo(val)
|
||||
}
|
||||
// Decode query: limit.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "limit",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotLimitVal int32
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt32(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotLimitVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Limit.SetTo(paramsDotLimitVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Limit.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Int{
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 100,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
MultipleOf: 0,
|
||||
Pattern: nil,
|
||||
}).Validate(int64(value)); err != nil {
|
||||
return errors.Wrap(err, "int")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "limit",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: cursor.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "cursor",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotCursorVal string
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotCursorVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Cursor.SetTo(paramsDotCursorVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Cursor.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 512,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9_-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "cursor",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListMyInvitationsParams is parameters of ListMyInvitations operation.
|
||||
type ListMyInvitationsParams struct {
|
||||
// Maximum number of items in the page. The server may return fewer items even when more remain; use
|
||||
@@ -2577,6 +2999,182 @@ func decodeListMyOrganizationsParams(args [0]string, argsEscaped bool, r *http.R
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListMyPrivacyHistoryParams is parameters of ListMyPrivacyHistory operation.
|
||||
type ListMyPrivacyHistoryParams struct {
|
||||
// Maximum number of items in the page. The server may return fewer items even when more remain; use
|
||||
// `page.has_more` to detect the end.
|
||||
Limit OptInt32 `json:",omitempty,omitzero"`
|
||||
// Opaque `page.next_cursor` value from the previous page of the same listing. Omit it to read the
|
||||
// first page. A malformed or foreign cursor returns 400 with code validation_failed.
|
||||
Cursor OptString `json:",omitempty,omitzero"`
|
||||
}
|
||||
|
||||
func unpackListMyPrivacyHistoryParams(packed middleware.Parameters) (params ListMyPrivacyHistoryParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "limit",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Limit = v.(OptInt32)
|
||||
}
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "cursor",
|
||||
In: "query",
|
||||
}
|
||||
if v, ok := packed[key]; ok {
|
||||
params.Cursor = v.(OptString)
|
||||
}
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeListMyPrivacyHistoryParams(args [0]string, argsEscaped bool, r *http.Request) (params ListMyPrivacyHistoryParams, _ error) {
|
||||
q := uri.NewQueryDecoder(r.URL.Query())
|
||||
// Set default value for query: limit.
|
||||
{
|
||||
val := int32(20)
|
||||
params.Limit.SetTo(val)
|
||||
}
|
||||
// Decode query: limit.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "limit",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotLimitVal int32
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToInt32(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotLimitVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Limit.SetTo(paramsDotLimitVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Limit.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.Int{
|
||||
MinSet: true,
|
||||
Min: 1,
|
||||
MaxSet: true,
|
||||
Max: 100,
|
||||
MinExclusive: false,
|
||||
MaxExclusive: false,
|
||||
MultipleOfSet: false,
|
||||
MultipleOf: 0,
|
||||
Pattern: nil,
|
||||
}).Validate(int64(value)); err != nil {
|
||||
return errors.Wrap(err, "int")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "limit",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode query: cursor.
|
||||
if err := func() error {
|
||||
cfg := uri.QueryParameterDecodingConfig{
|
||||
Name: "cursor",
|
||||
Style: uri.QueryStyleForm,
|
||||
Explode: true,
|
||||
}
|
||||
|
||||
if err := q.HasParam(cfg); err == nil {
|
||||
if err := q.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
var paramsDotCursorVal string
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
paramsDotCursorVal = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
params.Cursor.SetTo(paramsDotCursorVal)
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := params.Cursor.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 512,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9_-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "cursor",
|
||||
In: "query",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ListMySupportCasesParams is parameters of ListMySupportCases operation.
|
||||
type ListMySupportCasesParams struct {
|
||||
// Maximum number of items in the page. The server may return fewer items even when more remain; use
|
||||
@@ -3874,6 +4472,76 @@ func decodeSubmitMyAssessmentAnswerParams(args [1]string, argsEscaped bool, r *h
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UnhideOrganizationParams is parameters of UnhideOrganization operation.
|
||||
type UnhideOrganizationParams struct {
|
||||
// Identifier of the organization that the current candidate hides or stops hiding the profile from. It
|
||||
// names the target of a candidate's own setting and grants the candidate nothing about the
|
||||
// organization. Hiding answers the same 404 not_found for an organization that does not exist and for
|
||||
// one that the candidate cannot see, so organizations cannot be enumerated; lifting the hiding answers
|
||||
// 204 for any well-formed identifier.
|
||||
OrgID uuid.UUID
|
||||
}
|
||||
|
||||
func unpackUnhideOrganizationParams(packed middleware.Parameters) (params UnhideOrganizationParams) {
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "org_id",
|
||||
In: "path",
|
||||
}
|
||||
params.OrgID = packed[key].(uuid.UUID)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeUnhideOrganizationParams(args [1]string, argsEscaped bool, r *http.Request) (params UnhideOrganizationParams, _ error) {
|
||||
// Decode path: org_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
if argsEscaped {
|
||||
unescaped, err := url.PathUnescape(args[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unescape path")
|
||||
}
|
||||
param = unescaped
|
||||
}
|
||||
if len(param) > 0 {
|
||||
d := uri.NewPathDecoder(uri.PathDecoderConfig{
|
||||
Param: "org_id",
|
||||
Value: param,
|
||||
Style: uri.PathStyleSimple,
|
||||
Explode: false,
|
||||
})
|
||||
|
||||
if err := func() error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToUUID(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.OrgID = c
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return validate.ErrFieldRequired
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "org_id",
|
||||
In: "path",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// UpdateOrganizationParams is parameters of UpdateOrganization operation.
|
||||
type UpdateOrganizationParams struct {
|
||||
// Identifier of an organization. Access comes only from an active membership of the session account in
|
||||
|
||||
@@ -1357,6 +1357,164 @@ func (s *Server) decodeSendOrganizationInvitationRequest(r *http.Request) (
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSetMyPublicationRequest(r *http.Request) (
|
||||
req *PublicationUpdate,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request PublicationUpdate
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSetMySearchStatusRequest(r *http.Request) (
|
||||
req *SearchStatusUpdate,
|
||||
rawBody []byte,
|
||||
close func() error,
|
||||
rerr error,
|
||||
) {
|
||||
var closers []func() error
|
||||
close = func() error {
|
||||
var merr error
|
||||
// Close in reverse order, to match defer behavior.
|
||||
for i := len(closers) - 1; i >= 0; i-- {
|
||||
c := closers[i]
|
||||
merr = errors.Join(merr, c())
|
||||
}
|
||||
return merr
|
||||
}
|
||||
defer func() {
|
||||
if rerr != nil {
|
||||
rerr = errors.Join(rerr, close())
|
||||
}
|
||||
}()
|
||||
ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type"))
|
||||
if err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "parse media type")
|
||||
}
|
||||
switch {
|
||||
case ct == "application/json":
|
||||
if r.ContentLength == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
buf, err := io.ReadAll(r.Body)
|
||||
defer func() {
|
||||
_ = r.Body.Close()
|
||||
}()
|
||||
if err != nil {
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
|
||||
// Reset the body to allow for downstream reading.
|
||||
r.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
|
||||
if len(buf) == 0 {
|
||||
return req, rawBody, close, validate.ErrBodyRequired
|
||||
}
|
||||
|
||||
rawBody = append(rawBody, buf...)
|
||||
d := jx.DecodeBytes(buf)
|
||||
|
||||
var request SearchStatusUpdate
|
||||
if err := func() error {
|
||||
if err := request.Decode(d); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := d.Skip(); err != io.EOF {
|
||||
return errors.New("unexpected trailing data")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
err = &ogenerrors.DecodeBodyError{
|
||||
ContentType: ct,
|
||||
Body: buf,
|
||||
Err: err,
|
||||
}
|
||||
return req, rawBody, close, err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := request.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return req, rawBody, close, errors.Wrap(err, "validate")
|
||||
}
|
||||
return &request, rawBody, close, nil
|
||||
default:
|
||||
return req, rawBody, close, validate.InvalidContentType(ct)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) decodeSubmitMyAssessmentAnswerRequest(r *http.Request) (
|
||||
req *AssessmentAnswerSubmission,
|
||||
rawBody []byte,
|
||||
|
||||
@@ -1683,6 +1683,65 @@ func encodeGetMyAssessmentResultResponse(response GetMyAssessmentResultRes, w ht
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyCardPreviewResponse(response GetMyCardPreviewRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CardPreviewHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyCardPreviewUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyCardPreviewForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyInvitationResponse(response GetMyInvitationRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateInvitationHeaders:
|
||||
@@ -1766,6 +1825,65 @@ func encodeGetMyInvitationResponse(response GetMyInvitationRes, w http.ResponseW
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyPrivacySettingsResponse(response GetMyPrivacySettingsRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *PrivacySettingsHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyPrivacySettingsUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *GetMyPrivacySettingsForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeGetMyProfileResponse(response GetMyProfileRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateProfileHeaders:
|
||||
@@ -2300,6 +2418,204 @@ func encodeGetSpecializationCatalogResponse(response *SpecializationCatalog, w h
|
||||
return nil
|
||||
}
|
||||
|
||||
func encodeHideOrganizationResponse(response HideOrganizationRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *HiddenOrganizationHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *HideOrganizationBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *HideOrganizationUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *HideOrganizationForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *HideOrganizationNotFound:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(404)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *HideOrganizationConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *TooManyRequestsHeaders:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.Header().Set("Access-Control-Expose-Headers", "Retry-After")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Retry-After" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Retry-After",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
if val, ok := response.RetryAfter.Get(); ok {
|
||||
return e.EncodeValue(conv.Int32ToString(val))
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Retry-After header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(429)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListMyCardAccessHistoryResponse(response ListMyCardAccessHistoryRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CardAccessListHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyCardAccessHistoryBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyCardAccessHistoryUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyCardAccessHistoryForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListMyConsentsResponse(response ListMyConsentsRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *ConsentRecordListHeaders:
|
||||
@@ -2359,6 +2675,77 @@ func encodeListMyConsentsResponse(response ListMyConsentsRes, w http.ResponseWri
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListMyHiddenOrganizationsResponse(response ListMyHiddenOrganizationsRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *HiddenOrganizationListHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyHiddenOrganizationsBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyHiddenOrganizationsUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyHiddenOrganizationsForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListMyInvitationsResponse(response ListMyInvitationsRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *CandidateInvitationListHeaders:
|
||||
@@ -2501,6 +2888,77 @@ func encodeListMyOrganizationsResponse(response ListMyOrganizationsRes, w http.R
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListMyPrivacyHistoryResponse(response ListMyPrivacyHistoryRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *PrivacyEventListHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyPrivacyHistoryBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyPrivacyHistoryUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *ListMyPrivacyHistoryForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeListMySupportCasesResponse(response ListMySupportCasesRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *SupportCaseListHeaders:
|
||||
@@ -3554,6 +4012,184 @@ func encodeSendOrganizationInvitationResponse(response SendOrganizationInvitatio
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSetMyPublicationResponse(response SetMyPublicationRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *PublicationHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMyPublicationBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMyPublicationUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMyPublicationForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMyPublicationConflict:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(409)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMyPublicationPreconditionFailed:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(412)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSetMySearchStatusResponse(response SetMySearchStatusRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *SearchStatusHeaders:
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(200)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMySearchStatusBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMySearchStatusUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMySearchStatusForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *SetMySearchStatusPreconditionFailed:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(412)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeSubmitMyAssessmentAnswerResponse(response SubmitMyAssessmentAnswerRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *AssessmentAttemptHeaders:
|
||||
@@ -3705,6 +4341,70 @@ func encodeSubmitMyAssessmentAnswerResponse(response SubmitMyAssessmentAnswerRes
|
||||
}
|
||||
}
|
||||
|
||||
func encodeUnhideOrganizationResponse(response UnhideOrganizationRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *UnhideOrganizationNoContent:
|
||||
// Encoding response headers.
|
||||
{
|
||||
h := uri.NewHeaderEncoder(w.Header())
|
||||
// Encode "Cache-Control" header.
|
||||
{
|
||||
cfg := uri.HeaderParameterEncodingConfig{
|
||||
Name: "Cache-Control",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.EncodeParam(cfg, func(e uri.Encoder) error {
|
||||
return e.EncodeValue(conv.StringToString(string(response.CacheControl)))
|
||||
}); err != nil {
|
||||
return errors.Wrap(err, "encode Cache-Control header")
|
||||
}
|
||||
}
|
||||
}
|
||||
w.WriteHeader(204)
|
||||
|
||||
return nil
|
||||
|
||||
case *UnhideOrganizationBadRequest:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(400)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *UnhideOrganizationUnauthorized:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(401)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
case *UnhideOrganizationForbidden:
|
||||
w.Header().Set("Content-Type", "application/problem+json")
|
||||
w.WriteHeader(403)
|
||||
|
||||
e := new(jx.Encoder)
|
||||
response.Encode(e)
|
||||
if _, err := e.WriteTo(w); err != nil {
|
||||
return errors.Wrap(err, "write")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
default:
|
||||
return errors.Errorf("unexpected response type: %T", response)
|
||||
}
|
||||
}
|
||||
|
||||
func encodeUpdateOrganizationResponse(response UpdateOrganizationRes, w http.ResponseWriter, span trace.Span) error {
|
||||
switch response := response.(type) {
|
||||
case *OrganizationHeaders:
|
||||
|
||||
@@ -11,16 +11,16 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
rn49AllowedHeaders = map[string]string{
|
||||
rn59AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn7AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn47AllowedHeaders = map[string]string{
|
||||
rn57AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key",
|
||||
}
|
||||
rn44AllowedHeaders = map[string]string{
|
||||
rn54AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
}
|
||||
rn25AllowedHeaders = map[string]string{
|
||||
@@ -29,7 +29,7 @@ var (
|
||||
rn9AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn52AllowedHeaders = map[string]string{
|
||||
rn65AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn20AllowedHeaders = map[string]string{
|
||||
@@ -44,13 +44,23 @@ var (
|
||||
rn17AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn53AllowedHeaders = map[string]string{
|
||||
rn66AllowedHeaders = map[string]string{
|
||||
"POST": "X-Csrf-Token",
|
||||
}
|
||||
rn31AllowedHeaders = map[string]string{
|
||||
rn46AllowedHeaders = map[string]string{
|
||||
"DELETE": "X-Csrf-Token",
|
||||
"PUT": "X-Csrf-Token",
|
||||
}
|
||||
rn63AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn32AllowedHeaders = map[string]string{
|
||||
rn64AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn34AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn35AllowedHeaders = map[string]string{
|
||||
"PUT": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn10AllowedHeaders = map[string]string{
|
||||
@@ -65,22 +75,22 @@ var (
|
||||
rn14AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn36AllowedHeaders = map[string]string{
|
||||
rn39AllowedHeaders = map[string]string{
|
||||
"PATCH": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
rn46AllowedHeaders = map[string]string{
|
||||
rn56AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn51AllowedHeaders = map[string]string{
|
||||
rn61AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn54AllowedHeaders = map[string]string{
|
||||
rn67AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn16AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type,Idempotency-Key,X-Csrf-Token",
|
||||
}
|
||||
rn39AllowedHeaders = map[string]string{
|
||||
rn42AllowedHeaders = map[string]string{
|
||||
"PATCH": "Content-Type,X-Csrf-Token",
|
||||
}
|
||||
)
|
||||
@@ -237,7 +247,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn49AllowedHeaders,
|
||||
allowedHeaders: rn59AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -314,7 +324,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn47AllowedHeaders,
|
||||
allowedHeaders: rn57AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -338,7 +348,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn44AllowedHeaders,
|
||||
allowedHeaders: rn54AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -491,7 +501,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn52AllowedHeaders,
|
||||
allowedHeaders: rn65AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -782,7 +792,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn53AllowedHeaders,
|
||||
allowedHeaders: rn66AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -822,31 +832,304 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
case 'p': // Prefix: "profile"
|
||||
case 'p': // Prefix: "pr"
|
||||
|
||||
if l := len("profile"); len(elem) >= l && elem[0:l] == "profile" {
|
||||
if l := len("pr"); len(elem) >= l && elem[0:l] == "pr" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
case "PUT":
|
||||
s.handleSaveMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn31AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'i': // Prefix: "ivacy"
|
||||
|
||||
if l := len("ivacy"); len(elem) >= l && elem[0:l] == "ivacy" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyPrivacySettingsRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'a': // Prefix: "access-history"
|
||||
|
||||
if l := len("access-history"); len(elem) >= l && elem[0:l] == "access-history" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListMyCardAccessHistoryRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'h': // Prefix: "hi"
|
||||
|
||||
if l := len("hi"); len(elem) >= l && elem[0:l] == "hi" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'd': // Prefix: "dden-organizations"
|
||||
|
||||
if l := len("dden-organizations"); len(elem) >= l && elem[0:l] == "dden-organizations" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListMyHiddenOrganizationsRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "org_id"
|
||||
// Leaf parameter, slashes are prohibited
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx >= 0 {
|
||||
break
|
||||
}
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "DELETE":
|
||||
s.handleUnhideOrganizationRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
case "PUT":
|
||||
s.handleHideOrganizationRequest([1]string{
|
||||
args[0],
|
||||
}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "DELETE,PUT",
|
||||
allowedHeaders: rn46AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 's': // Prefix: "story"
|
||||
|
||||
if l := len("story"); len(elem) >= l && elem[0:l] == "story" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleListMyPrivacyHistoryRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'p': // Prefix: "p"
|
||||
|
||||
if l := len("p"); len(elem) >= l && elem[0:l] == "p" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'r': // Prefix: "review"
|
||||
|
||||
if l := len("review"); len(elem) >= l && elem[0:l] == "review" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyCardPreviewRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET",
|
||||
allowedHeaders: nil,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'u': // Prefix: "ublication"
|
||||
|
||||
if l := len("ublication"); len(elem) >= l && elem[0:l] == "ublication" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PUT":
|
||||
s.handleSetMyPublicationRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "PUT",
|
||||
allowedHeaders: rn63AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 's': // Prefix: "search-status"
|
||||
|
||||
if l := len("search-status"); len(elem) >= l && elem[0:l] == "search-status" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "PUT":
|
||||
s.handleSetMySearchStatusRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "PUT",
|
||||
allowedHeaders: rn64AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'o': // Prefix: "ofile"
|
||||
|
||||
if l := len("ofile"); len(elem) >= l && elem[0:l] == "ofile" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch r.Method {
|
||||
case "GET":
|
||||
s.handleGetMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
case "PUT":
|
||||
s.handleSaveMyProfileRequest([0]string{}, elemIsEscaped, w, r)
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn34AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
case 'q': // Prefix: "questionnaire"
|
||||
@@ -867,7 +1150,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PUT",
|
||||
allowedHeaders: rn32AllowedHeaders,
|
||||
allowedHeaders: rn35AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1079,7 +1362,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PATCH",
|
||||
allowedHeaders: rn36AllowedHeaders,
|
||||
allowedHeaders: rn39AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "application/json",
|
||||
})
|
||||
@@ -1159,7 +1442,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn46AllowedHeaders,
|
||||
allowedHeaders: rn56AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1187,7 +1470,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn51AllowedHeaders,
|
||||
allowedHeaders: rn61AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1217,7 +1500,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "POST",
|
||||
allowedHeaders: rn54AllowedHeaders,
|
||||
allowedHeaders: rn67AllowedHeaders,
|
||||
acceptPost: "application/json",
|
||||
acceptPatch: "",
|
||||
})
|
||||
@@ -1295,7 +1578,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
default:
|
||||
s.notAllowed(w, r, notAllowedParams{
|
||||
allowedMethods: "GET,PATCH",
|
||||
allowedHeaders: rn39AllowedHeaders,
|
||||
allowedHeaders: rn42AllowedHeaders,
|
||||
acceptPost: "",
|
||||
acceptPatch: "application/json",
|
||||
})
|
||||
@@ -2110,38 +2393,314 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) {
|
||||
}
|
||||
}
|
||||
|
||||
case 'p': // Prefix: "profile"
|
||||
case 'p': // Prefix: "pr"
|
||||
|
||||
if l := len("profile"); len(elem) >= l && elem[0:l] == "profile" {
|
||||
if l := len("pr"); len(elem) >= l && elem[0:l] == "pr" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyProfileOperation
|
||||
r.summary = "Read the private profile of the current candidate."
|
||||
r.operationID = "GetMyProfile"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "PUT":
|
||||
r.name = SaveMyProfileOperation
|
||||
r.summary = "Replace the private profile of the current candidate."
|
||||
r.operationID = "SaveMyProfile"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'i': // Prefix: "ivacy"
|
||||
|
||||
if l := len("ivacy"); len(elem) >= l && elem[0:l] == "ivacy" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyPrivacySettingsOperation
|
||||
r.summary = "Read the visibility settings of the current candidate."
|
||||
r.operationID = "GetMyPrivacySettings"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'a': // Prefix: "access-history"
|
||||
|
||||
if l := len("access-history"); len(elem) >= l && elem[0:l] == "access-history" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = ListMyCardAccessHistoryOperation
|
||||
r.summary = "List the accesses of organizations to the card of the current candidate."
|
||||
r.operationID = "ListMyCardAccessHistory"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/access-history"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'h': // Prefix: "hi"
|
||||
|
||||
if l := len("hi"); len(elem) >= l && elem[0:l] == "hi" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'd': // Prefix: "dden-organizations"
|
||||
|
||||
if l := len("dden-organizations"); len(elem) >= l && elem[0:l] == "dden-organizations" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = ListMyHiddenOrganizationsOperation
|
||||
r.summary = "List the organizations that the candidate hides the profile from."
|
||||
r.operationID = "ListMyHiddenOrganizations"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/hidden-organizations"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
switch elem[0] {
|
||||
case '/': // Prefix: "/"
|
||||
|
||||
if l := len("/"); len(elem) >= l && elem[0:l] == "/" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
// Param: "org_id"
|
||||
// Leaf parameter, slashes are prohibited
|
||||
idx := strings.IndexByte(elem, '/')
|
||||
if idx >= 0 {
|
||||
break
|
||||
}
|
||||
args[0] = elem
|
||||
elem = ""
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "DELETE":
|
||||
r.name = UnhideOrganizationOperation
|
||||
r.summary = "Lift the hiding of the candidate profile from one organization."
|
||||
r.operationID = "UnhideOrganization"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/hidden-organizations/{org_id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
case "PUT":
|
||||
r.name = HideOrganizationOperation
|
||||
r.summary = "Hide the candidate profile from one organization."
|
||||
r.operationID = "HideOrganization"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/hidden-organizations/{org_id}"
|
||||
r.args = args
|
||||
r.count = 1
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 's': // Prefix: "story"
|
||||
|
||||
if l := len("story"); len(elem) >= l && elem[0:l] == "story" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = ListMyPrivacyHistoryOperation
|
||||
r.summary = "List the changes of the visibility settings of the current candidate."
|
||||
r.operationID = "ListMyPrivacyHistory"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/history"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'p': // Prefix: "p"
|
||||
|
||||
if l := len("p"); len(elem) >= l && elem[0:l] == "p" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
break
|
||||
}
|
||||
switch elem[0] {
|
||||
case 'r': // Prefix: "review"
|
||||
|
||||
if l := len("review"); len(elem) >= l && elem[0:l] == "review" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyCardPreviewOperation
|
||||
r.summary = "Preview the anonymous card that organizations would read."
|
||||
r.operationID = "GetMyCardPreview"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/preview"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
case 'u': // Prefix: "ublication"
|
||||
|
||||
if l := len("ublication"); len(elem) >= l && elem[0:l] == "ublication" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PUT":
|
||||
r.name = SetMyPublicationOperation
|
||||
r.summary = "Publish or close the anonymous candidate card."
|
||||
r.operationID = "SetMyPublication"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/publication"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 's': // Prefix: "search-status"
|
||||
|
||||
if l := len("search-status"); len(elem) >= l && elem[0:l] == "search-status" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "PUT":
|
||||
r.name = SetMySearchStatusOperation
|
||||
r.summary = "Set or confirm the search status of the current candidate."
|
||||
r.operationID = "SetMySearchStatus"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/privacy/search-status"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'o': // Prefix: "ofile"
|
||||
|
||||
if l := len("ofile"); len(elem) >= l && elem[0:l] == "ofile" {
|
||||
elem = elem[l:]
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
if len(elem) == 0 {
|
||||
// Leaf node.
|
||||
switch method {
|
||||
case "GET":
|
||||
r.name = GetMyProfileOperation
|
||||
r.summary = "Read the private profile of the current candidate."
|
||||
r.operationID = "GetMyProfile"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
case "PUT":
|
||||
r.name = SaveMyProfileOperation
|
||||
r.summary = "Replace the private profile of the current candidate."
|
||||
r.operationID = "SaveMyProfile"
|
||||
r.operationGroup = ""
|
||||
r.pathPattern = "/api/v1/me/profile"
|
||||
r.args = args
|
||||
r.count = 0
|
||||
return r, true
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
case 'q': // Prefix: "questionnaire"
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -70,7 +70,9 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
GetMyAssessmentAttemptOperation: []string{},
|
||||
GetMyAssessmentAvailabilityOperation: []string{},
|
||||
GetMyAssessmentResultOperation: []string{},
|
||||
GetMyCardPreviewOperation: []string{},
|
||||
GetMyInvitationOperation: []string{},
|
||||
GetMyPrivacySettingsOperation: []string{},
|
||||
GetMyProfileOperation: []string{},
|
||||
GetMyQuestionnaireOperation: []string{},
|
||||
GetMySupportCaseOperation: []string{},
|
||||
@@ -78,9 +80,13 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
GetOrganizationInvitationOperation: []string{},
|
||||
GetOrganizationInvitationContactsOperation: []string{},
|
||||
GetOrganizationNeedOperation: []string{},
|
||||
HideOrganizationOperation: []string{},
|
||||
ListMyCardAccessHistoryOperation: []string{},
|
||||
ListMyConsentsOperation: []string{},
|
||||
ListMyHiddenOrganizationsOperation: []string{},
|
||||
ListMyInvitationsOperation: []string{},
|
||||
ListMyOrganizationsOperation: []string{},
|
||||
ListMyPrivacyHistoryOperation: []string{},
|
||||
ListMySupportCasesOperation: []string{},
|
||||
ListOrganizationInvitationsOperation: []string{},
|
||||
ListOrganizationNeedsOperation: []string{},
|
||||
@@ -89,7 +95,10 @@ var operationRolesSessionCookie = map[string][]string{
|
||||
SaveMyProfileOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
SendOrganizationInvitationOperation: []string{},
|
||||
SetMyPublicationOperation: []string{},
|
||||
SetMySearchStatusOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
UnhideOrganizationOperation: []string{},
|
||||
UpdateOrganizationOperation: []string{},
|
||||
UpdateOrganizationInvitationOperation: []string{},
|
||||
UpdateOrganizationNeedOperation: []string{},
|
||||
@@ -129,12 +138,16 @@ var operationRolesSessionCsrf = map[string][]string{
|
||||
CreateOrganizationNeedOperation: []string{},
|
||||
DeclineMyInvitationOperation: []string{},
|
||||
FinalizeMyAssessmentAttemptOperation: []string{},
|
||||
HideOrganizationOperation: []string{},
|
||||
LogoutOperation: []string{},
|
||||
RaiseOrganizationInvitationSalaryOperation: []string{},
|
||||
SaveMyProfileOperation: []string{},
|
||||
SaveMyQuestionnaireOperation: []string{},
|
||||
SendOrganizationInvitationOperation: []string{},
|
||||
SetMyPublicationOperation: []string{},
|
||||
SetMySearchStatusOperation: []string{},
|
||||
SubmitMyAssessmentAnswerOperation: []string{},
|
||||
UnhideOrganizationOperation: []string{},
|
||||
UpdateOrganizationOperation: []string{},
|
||||
UpdateOrganizationInvitationOperation: []string{},
|
||||
UpdateOrganizationNeedOperation: []string{},
|
||||
|
||||
@@ -572,6 +572,29 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/me/assessment-attempts/{attempt_id}/result
|
||||
GetMyAssessmentResult(ctx context.Context, params GetMyAssessmentResultParams) (GetMyAssessmentResultRes, error)
|
||||
// GetMyCardPreview implements GetMyCardPreview operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the card exactly as an organization that
|
||||
// the candidate does not hide the profile from would read it now, built from the current profile, the
|
||||
// current publication, and the consent ledger. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// The preview is a private read for the candidate: it creates no view, leaves no access record, and is
|
||||
// never shown to an organization. While the profile is closed `card` is null. `card` is
|
||||
// `AnonymousCardContent`, whose schema reaches no private profile schema, no contact, and no
|
||||
// identifier of the candidate: it has no name, email, phone, Telegram name, employer, salary figure,
|
||||
// or account or profile identifier, and each property is null when it is not published or has no
|
||||
// value, so a reader cannot tell the two apart. Only the fields in `fields` are filled, and only with
|
||||
// values that the candidate confirmed: an unconfirmed suggestion and an unknown value never appear. A
|
||||
// free text value that looks like a contact (an email address, a phone number, a URL, a Telegram link,
|
||||
// an @handle) is dropped from the card, so the preview shows exactly what an organization would read.
|
||||
// The self-assessed grade is not a category and never appears; categories come only from assessment
|
||||
// results.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/privacy/preview
|
||||
GetMyCardPreview(ctx context.Context) (GetMyCardPreviewRes, error)
|
||||
// GetMyInvitation implements GetMyInvitation operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session; the
|
||||
@@ -603,6 +626,27 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/me/invitations/{invitation_id}
|
||||
GetMyInvitation(ctx context.Context, params GetMyInvitationParams) (GetMyInvitationRes, error)
|
||||
// GetMyPrivacySettings implements GetMyPrivacySettings operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
// a request parameter. Returns the publication of the candidate card, the search status, and the
|
||||
// number of hidden organizations in one read. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// A profile is closed by default. A candidate who never published reads `publication.state` `closed`
|
||||
// with `closed_reason` `never_published`, an empty field set, and version 0; creating or saving the
|
||||
// profile (`SaveMyProfile`) never publishes it, and no operation of the profile, the questionnaire, or
|
||||
// an assessment changes these settings. The C2 consent, the search status, and the hidden
|
||||
// organizations are three independent settings: the C2 record in the consent ledger proves that the
|
||||
// candidate accepted the publication text, the publication records which fields are published, and the
|
||||
// search status is a statement of the candidate that is not a consent. A change of one never changes
|
||||
// another, and none of them ever makes the candidate more visible by itself: the search status lapses
|
||||
// to the non-public `not_looking`, a revoked C2 closes the card, and a new C2 grant publishes nothing.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/privacy
|
||||
GetMyPrivacySettings(ctx context.Context) (GetMyPrivacySettingsRes, error)
|
||||
// GetMyProfile implements GetMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -795,6 +839,66 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/specializations
|
||||
GetSpecializationCatalog(ctx context.Context) (*SpecializationCatalog, error)
|
||||
// HideOrganization implements HideOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The request has no body: the path names the organization and the candidate
|
||||
// comes from the session. The hiding is a record that belongs to the candidate and references the
|
||||
// organization; it changes neither the C2 consent, nor the publication, nor the search status.
|
||||
//
|
||||
// The operation sets a state, so it is idempotent and needs no Idempotency-Key: hiding an organization
|
||||
// that is already hidden answers 200 with the existing record and its original `hidden_at`, changes
|
||||
// nothing, and writes no history record. There is one record per candidate and organization.
|
||||
//
|
||||
// Anti-enumeration: an organization that does not exist and an organization that the candidate cannot
|
||||
// see answer the same 404 not_found, with the same body and without a timing or an error code that
|
||||
// tells them apart, so the operation is not a way to ask whether an identifier belongs to an
|
||||
// organization. The candidate can see an organization that has sent them an invitation, and the
|
||||
// organizations that a candidate lookup will list (planned; see the open questions of the contract).
|
||||
// The response names the organization only after that check, with its current name. The identifiers
|
||||
// are random, the general rate limit applies and can answer 429 with Retry-After before any check, and
|
||||
// the record never reveals to an organization that a candidate hides it.
|
||||
//
|
||||
// A candidate hides at most 1000 organizations; hiding one more answers 409 state_conflict with the
|
||||
// entry `{in: path, pointer: /org_id, code: limit_reached}` in `errors`, which tells it apart from
|
||||
// other conflicts, and changes nothing, and a repeat of an existing hiding is never refused for the
|
||||
// limit.
|
||||
//
|
||||
// Hiding an organization that holds an active contact grant of the candidate revokes that grant with
|
||||
// the reason `visibility_closed` in the same transaction (planned together with the invitation
|
||||
// operations). Lifting the hiding never reopens a grant.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the
|
||||
// path (400), account scenario (403 forbidden for an employer), the organization and its visibility to
|
||||
// the candidate (404 not_found), then the repeat (200), then the limit (409 state_conflict). Like
|
||||
// every visibility change, hiding needs a verified email (a usecase requirement).
|
||||
//
|
||||
// PUT /api/v1/me/privacy/hidden-organizations/{org_id}
|
||||
HideOrganization(ctx context.Context, params HideOrganizationParams) (HideOrganizationRes, error)
|
||||
// ListMyCardAccessHistory implements ListMyCardAccessHistory operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
|
||||
// response holds only accesses to the caller's own card. Returns a page, newest first with the record
|
||||
// identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// An access is a view of the anonymous card by an organization (`card_viewed`) or a read of the
|
||||
// contacts through an active contact grant (`contact_read`). Reading the history is not an access and
|
||||
// writes nothing. A view of the card by an organization that has no invitation relation with the
|
||||
// candidate carries `organization` null, so the candidate sees that the card was viewed without
|
||||
// learning a company that they cannot otherwise see; a contact read always names the organization,
|
||||
// because the candidate accepted its invitation. The entries carry no search query, filter, or ranking
|
||||
// of the organization, and no organization the candidate hides ever appears as a viewer, because a
|
||||
// hidden organization cannot read the card.
|
||||
//
|
||||
// The storage of accesses is planned with the card and contact operations of the organization side
|
||||
// (TASK-185 and the contact read of the invitation contract); until then the operation answers 501
|
||||
// not_implemented after the session and request checks.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
|
||||
//
|
||||
// GET /api/v1/me/privacy/access-history
|
||||
ListMyCardAccessHistory(ctx context.Context, params ListMyCardAccessHistoryParams) (ListMyCardAccessHistoryRes, error)
|
||||
// ListMyConsents implements ListMyConsents operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate or an employer account. The subject comes from the
|
||||
@@ -824,6 +928,22 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/me/consents
|
||||
ListMyConsents(ctx context.Context, params ListMyConsentsParams) (ListMyConsentsRes, error)
|
||||
// ListMyHiddenOrganizations implements ListMyHiddenOrganizations operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
|
||||
// response holds only the caller's own records and no request can name another account. Returns a page
|
||||
// of the hidden organizations, newest first with the organization identifier as the tie-breaker, with
|
||||
// cursor pagination. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// The records belong to the candidate. An organization never reads them, never learns that it is
|
||||
// hidden, and sees a hidden candidate exactly as it sees one who is not published: no search result,
|
||||
// no card, no contact read.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
|
||||
//
|
||||
// GET /api/v1/me/privacy/hidden-organizations
|
||||
ListMyHiddenOrganizations(ctx context.Context, params ListMyHiddenOrganizationsParams) (ListMyHiddenOrganizationsRes, error)
|
||||
// ListMyInvitations implements ListMyInvitations operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -871,6 +991,24 @@ type Handler interface {
|
||||
//
|
||||
// GET /api/v1/me/organizations
|
||||
ListMyOrganizations(ctx context.Context, params ListMyOrganizationsParams) (ListMyOrganizationsRes, error)
|
||||
// ListMyPrivacyHistory implements ListMyPrivacyHistory operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
|
||||
// response holds only the caller's own records. Returns a page of the settings history, newest first
|
||||
// with the event identifier as the tie-breaker, with cursor pagination. The response is
|
||||
// `Cache-Control: no-store`.
|
||||
//
|
||||
// The history is append-only evidence of what the candidate published, hid, and announced, and when. A
|
||||
// publication event keeps the published fields and the C2 record behind them, which is what the
|
||||
// consent ledger deliberately does not carry (the C2 record proves the consent to the text, not the
|
||||
// field set). A revocation of C2 and a lapse of the search status are computed and are not events
|
||||
// here; the consent history shows the revocation. The history never contains a profile value.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
|
||||
//
|
||||
// GET /api/v1/me/privacy/history
|
||||
ListMyPrivacyHistory(ctx context.Context, params ListMyPrivacyHistoryParams) (ListMyPrivacyHistoryRes, error)
|
||||
// ListMySupportCases implements ListMySupportCases operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate or an employer account. Returns a page of the cases that
|
||||
@@ -1186,6 +1324,90 @@ type Handler interface {
|
||||
//
|
||||
// POST /api/v1/organizations/{org_id}/invitations/{invitation_id}/send
|
||||
SendOrganizationInvitation(ctx context.Context, req *InvitationCommand, params SendOrganizationInvitationParams) (SendOrganizationInvitationRes, error)
|
||||
// SetMyPublication implements SetMyPublication operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new publication setting: `state` `published` with
|
||||
// the non-empty set of card fields, or `closed` with an empty set. It changes only the publication;
|
||||
// the search status and the hidden organizations stay as they were.
|
||||
//
|
||||
// Publication is not a consent and does not duplicate one. The consent C2 lives in the consent ledger
|
||||
// (`ListMyConsents`); this setting refers to it. Publishing requires an active, unrevoked C2 record of
|
||||
// the account and binds the publication to that record, so a client sends no consent identifier and
|
||||
// cannot forge one. Without one the server answers 409 state_conflict with the entry
|
||||
// `{in: body, pointer: /state, code: consent_required}` in `errors`, which tells it apart from every
|
||||
// other conflict, and changes nothing: the client gives C2 first (planned in the consent settings,
|
||||
// TASK-063) and then publishes. The server takes the C2 record under a share lock in the transaction
|
||||
// that writes the publication, so a revocation that races with a publication either commits first (the
|
||||
// publication is refused) or closes the card right after. A revocation of C2 closes the card at once,
|
||||
// because `state` is computed from the unrevoked record; a later C2 grant never reopens it, and the
|
||||
// candidate publishes again under the new record. The revocation path itself (TASK-064) closes the
|
||||
// stored publication and revokes the contact grants in its own transaction. A closing sent over a
|
||||
// stored publication whose C2 was revoked is a real change: it stores the closing, records
|
||||
// `publication_closed`, and revokes the grants as any closing does. Publishing, like every visibility
|
||||
// change, needs a verified email (a usecase requirement; the unverified account cleanup deletes only
|
||||
// accounts without such records). Publishing never adds a field that the body did not name, and a new
|
||||
// `CardField` value is never published for a candidate who did not choose it.
|
||||
//
|
||||
// The field set contains only the groups of `CardField`. The full name, contacts, and the lowest
|
||||
// salary have no value there, so no body can publish them. Only values that the candidate confirmed
|
||||
// ever reach the card. Contacts reach an organization only through the contact grant (C4), and a
|
||||
// profile that is published or closed changes none of the grants that exist; closing the publication,
|
||||
// and hiding an organization that holds a grant, revoke the contact grants concerned with the reason
|
||||
// `visibility_closed` in the same transaction as the change (planned together with the operations, see
|
||||
// the invitation contract).
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read,
|
||||
// 0 for the first publication. If it is not the current version the server answers 412
|
||||
// version_conflict and changes nothing. The version travels in the body rather than in If-Match
|
||||
// because the generated client cannot read the ETag header yet. A body that equals the stored setting
|
||||
// changes nothing, keeps the version, and answers 200 even when `expected_version` is older, so a
|
||||
// retry after a lost response succeeds without an Idempotency-Key. A version above the current one
|
||||
// never existed and always answers 412. Every change is recorded in the settings history with its
|
||||
// time, the fields, and the C2 record.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), rules that
|
||||
// depend on the body alone (400), an unchanged body (200), a stale version (412), then the active C2
|
||||
// for a publication (409 state_conflict). The schema rejects an unknown field, a repeated or unknown
|
||||
// card field, and more fields than there are groups; a published state with no field, and a closed
|
||||
// state with a field, answer 400 validation_failed with the pointer `/fields`. Error bodies never
|
||||
// repeat a submitted value.
|
||||
//
|
||||
// PUT /api/v1/me/privacy/publication
|
||||
SetMyPublication(ctx context.Context, req *PublicationUpdate) (SetMyPublicationRes, error)
|
||||
// SetMySearchStatus implements SetMySearchStatus operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new status: `looking` ("Ищу") or `not_looking`.
|
||||
// The status is a statement of the candidate and never a consent. It changes neither the C2 consent,
|
||||
// nor the publication, nor the hidden organizations, and it does not close or open any contact grant;
|
||||
// a candidate whose profile is closed who sets `looking` becomes visible to no one.
|
||||
//
|
||||
// `looking` stores the moment of the confirmation and a lapse time. The server takes the interval from
|
||||
// the `search_status` section of the effective product policy (30 days in the demo policy,
|
||||
// `searching_confirmation_interval_days`), stores the policy version it used, and fixes the lapse time
|
||||
// then, so a later policy change moves no stored time. Setting `looking` again is the confirmation: it
|
||||
// replaces the confirmation time with now and advances the version, also after a lapse. The body
|
||||
// carries no time, interval, or policy version.
|
||||
//
|
||||
// After the lapse time the status holds as `not_looking` with `lapsed` true on the next read. The
|
||||
// lapse is computed and written nowhere, so it needs no job, it can never make the candidate more
|
||||
// visible, and it never touches the publication or the hidden organizations. A reminder before the
|
||||
// lapse is a planned notification, not a part of this operation.
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body, 0 for a candidate who never set the
|
||||
// status; a stale or non-existent version answers 412 version_conflict and changes nothing.
|
||||
// `not_looking` over a stored `not_looking` changes nothing and answers 200 even with a stale version.
|
||||
// `looking` always changes the stored confirmation, so a retry of a confirmation whose response was
|
||||
// lost with the old version answers 412 and the client reads the status again.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), an
|
||||
// unchanged `not_looking` (200), then a stale version (412).
|
||||
//
|
||||
// PUT /api/v1/me/privacy/search-status
|
||||
SetMySearchStatus(ctx context.Context, req *SearchStatusUpdate) (SetMySearchStatusRes, error)
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
@@ -1243,6 +1465,24 @@ type Handler interface {
|
||||
//
|
||||
// POST /api/v1/me/assessment-attempts/{attempt_id}/answers
|
||||
SubmitMyAssessmentAnswer(ctx context.Context, req *AssessmentAnswerSubmission, params SubmitMyAssessmentAnswerParams) (SubmitMyAssessmentAnswerRes, error)
|
||||
// UnhideOrganization implements UnhideOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. Deletes the hiding record of the candidate for the organization in the path.
|
||||
// The request is idempotent: it answers 204 whether the organization was hidden, was not hidden, or
|
||||
// does not exist, so the operation reveals nothing about the organization, and a repeat after a lost
|
||||
// response succeeds. The record is deleted, the settings history keeps the event
|
||||
// `organization_unhidden` only when a record was deleted.
|
||||
//
|
||||
// Lifting the hiding makes the candidate readable by that organization again only if the profile is
|
||||
// published and the organization otherwise may read it. It changes neither the C2 consent, nor the
|
||||
// publication, nor the search status, and it never reopens a contact grant that the hiding closed.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the
|
||||
// path (400), account scenario (403 forbidden for an employer), then the deletion (204).
|
||||
//
|
||||
// DELETE /api/v1/me/privacy/hidden-organizations/{org_id}
|
||||
UnhideOrganization(ctx context.Context, params UnhideOrganizationParams) (UnhideOrganizationRes, error)
|
||||
// UpdateOrganization implements UpdateOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of an employer account with an active membership in `org_id`, the CSRF
|
||||
|
||||
@@ -628,6 +628,32 @@ func (UnimplementedHandler) GetMyAssessmentResult(ctx context.Context, params Ge
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyCardPreview implements GetMyCardPreview operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. Returns the card exactly as an organization that
|
||||
// the candidate does not hide the profile from would read it now, built from the current profile, the
|
||||
// current publication, and the consent ledger. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// The preview is a private read for the candidate: it creates no view, leaves no access record, and is
|
||||
// never shown to an organization. While the profile is closed `card` is null. `card` is
|
||||
// `AnonymousCardContent`, whose schema reaches no private profile schema, no contact, and no
|
||||
// identifier of the candidate: it has no name, email, phone, Telegram name, employer, salary figure,
|
||||
// or account or profile identifier, and each property is null when it is not published or has no
|
||||
// value, so a reader cannot tell the two apart. Only the fields in `fields` are filled, and only with
|
||||
// values that the candidate confirmed: an unconfirmed suggestion and an unknown value never appear. A
|
||||
// free text value that looks like a contact (an email address, a phone number, a URL, a Telegram link,
|
||||
// an @handle) is dropped from the card, so the preview shows exactly what an organization would read.
|
||||
// The self-assessed grade is not a category and never appears; categories come only from assessment
|
||||
// results.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/privacy/preview
|
||||
func (UnimplementedHandler) GetMyCardPreview(ctx context.Context) (r GetMyCardPreviewRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyInvitation implements GetMyInvitation operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session; the
|
||||
@@ -662,6 +688,30 @@ func (UnimplementedHandler) GetMyInvitation(ctx context.Context, params GetMyInv
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyPrivacySettings implements GetMyPrivacySettings operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
// a request parameter. Returns the publication of the candidate card, the search status, and the
|
||||
// number of hidden organizations in one read. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// A profile is closed by default. A candidate who never published reads `publication.state` `closed`
|
||||
// with `closed_reason` `never_published`, an empty field set, and version 0; creating or saving the
|
||||
// profile (`SaveMyProfile`) never publishes it, and no operation of the profile, the questionnaire, or
|
||||
// an assessment changes these settings. The C2 consent, the search status, and the hidden
|
||||
// organizations are three independent settings: the C2 record in the consent ledger proves that the
|
||||
// candidate accepted the publication text, the publication records which fields are published, and the
|
||||
// search status is a statement of the candidate that is not a consent. A change of one never changes
|
||||
// another, and none of them ever makes the candidate more visible by itself: the search status lapses
|
||||
// to the non-public `not_looking`, a revoked C2 closes the card, and a new C2 grant publishes nothing.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden.
|
||||
//
|
||||
// GET /api/v1/me/privacy
|
||||
func (UnimplementedHandler) GetMyPrivacySettings(ctx context.Context) (r GetMyPrivacySettingsRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// GetMyProfile implements GetMyProfile operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -878,6 +928,72 @@ func (UnimplementedHandler) GetSpecializationCatalog(ctx context.Context) (r *Sp
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// HideOrganization implements HideOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The request has no body: the path names the organization and the candidate
|
||||
// comes from the session. The hiding is a record that belongs to the candidate and references the
|
||||
// organization; it changes neither the C2 consent, nor the publication, nor the search status.
|
||||
//
|
||||
// The operation sets a state, so it is idempotent and needs no Idempotency-Key: hiding an organization
|
||||
// that is already hidden answers 200 with the existing record and its original `hidden_at`, changes
|
||||
// nothing, and writes no history record. There is one record per candidate and organization.
|
||||
//
|
||||
// Anti-enumeration: an organization that does not exist and an organization that the candidate cannot
|
||||
// see answer the same 404 not_found, with the same body and without a timing or an error code that
|
||||
// tells them apart, so the operation is not a way to ask whether an identifier belongs to an
|
||||
// organization. The candidate can see an organization that has sent them an invitation, and the
|
||||
// organizations that a candidate lookup will list (planned; see the open questions of the contract).
|
||||
// The response names the organization only after that check, with its current name. The identifiers
|
||||
// are random, the general rate limit applies and can answer 429 with Retry-After before any check, and
|
||||
// the record never reveals to an organization that a candidate hides it.
|
||||
//
|
||||
// A candidate hides at most 1000 organizations; hiding one more answers 409 state_conflict with the
|
||||
// entry `{in: path, pointer: /org_id, code: limit_reached}` in `errors`, which tells it apart from
|
||||
// other conflicts, and changes nothing, and a repeat of an existing hiding is never refused for the
|
||||
// limit.
|
||||
//
|
||||
// Hiding an organization that holds an active contact grant of the candidate revokes that grant with
|
||||
// the reason `visibility_closed` in the same transaction (planned together with the invitation
|
||||
// operations). Lifting the hiding never reopens a grant.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the
|
||||
// path (400), account scenario (403 forbidden for an employer), the organization and its visibility to
|
||||
// the candidate (404 not_found), then the repeat (200), then the limit (409 state_conflict). Like
|
||||
// every visibility change, hiding needs a verified email (a usecase requirement).
|
||||
//
|
||||
// PUT /api/v1/me/privacy/hidden-organizations/{org_id}
|
||||
func (UnimplementedHandler) HideOrganization(ctx context.Context, params HideOrganizationParams) (r HideOrganizationRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMyCardAccessHistory implements ListMyCardAccessHistory operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
|
||||
// response holds only accesses to the caller's own card. Returns a page, newest first with the record
|
||||
// identifier as the tie-breaker, with cursor pagination. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// An access is a view of the anonymous card by an organization (`card_viewed`) or a read of the
|
||||
// contacts through an active contact grant (`contact_read`). Reading the history is not an access and
|
||||
// writes nothing. A view of the card by an organization that has no invitation relation with the
|
||||
// candidate carries `organization` null, so the candidate sees that the card was viewed without
|
||||
// learning a company that they cannot otherwise see; a contact read always names the organization,
|
||||
// because the candidate accepted its invitation. The entries carry no search query, filter, or ranking
|
||||
// of the organization, and no organization the candidate hides ever appears as a viewer, because a
|
||||
// hidden organization cannot read the card.
|
||||
//
|
||||
// The storage of accesses is planned with the card and contact operations of the organization side
|
||||
// (TASK-185 and the contact read of the invitation contract); until then the operation answers 501
|
||||
// not_implemented after the session and request checks.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
|
||||
//
|
||||
// GET /api/v1/me/privacy/access-history
|
||||
func (UnimplementedHandler) ListMyCardAccessHistory(ctx context.Context, params ListMyCardAccessHistoryParams) (r ListMyCardAccessHistoryRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMyConsents implements ListMyConsents operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate or an employer account. The subject comes from the
|
||||
@@ -910,6 +1026,25 @@ func (UnimplementedHandler) ListMyConsents(ctx context.Context, params ListMyCon
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMyHiddenOrganizations implements ListMyHiddenOrganizations operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
|
||||
// response holds only the caller's own records and no request can name another account. Returns a page
|
||||
// of the hidden organizations, newest first with the organization identifier as the tie-breaker, with
|
||||
// cursor pagination. The response is `Cache-Control: no-store`.
|
||||
//
|
||||
// The records belong to the candidate. An organization never reads them, never learns that it is
|
||||
// hidden, and sees a hidden candidate exactly as it sees one who is not published: no search result,
|
||||
// no card, no contact read.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
|
||||
//
|
||||
// GET /api/v1/me/privacy/hidden-organizations
|
||||
func (UnimplementedHandler) ListMyHiddenOrganizations(ctx context.Context, params ListMyHiddenOrganizationsParams) (r ListMyHiddenOrganizationsRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMyInvitations implements ListMyInvitations operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, never from
|
||||
@@ -963,6 +1098,27 @@ func (UnimplementedHandler) ListMyOrganizations(ctx context.Context, params List
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMyPrivacyHistory implements ListMyPrivacyHistory operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account. The candidate comes from the session, so the
|
||||
// response holds only the caller's own records. Returns a page of the settings history, newest first
|
||||
// with the event identifier as the tie-breaker, with cursor pagination. The response is
|
||||
// `Cache-Control: no-store`.
|
||||
//
|
||||
// The history is append-only evidence of what the candidate published, hid, and announced, and when. A
|
||||
// publication event keeps the published fields and the C2 record behind them, which is what the
|
||||
// consent ledger deliberately does not carry (the C2 record proves the consent to the text, not the
|
||||
// field set). A revocation of C2 and a lapse of the search status are computed and are not events
|
||||
// here; the consent history shows the revocation. The history never contains a profile value.
|
||||
//
|
||||
// A missing, unknown, expired, or revoked session answers 401 unauthenticated; an employer account
|
||||
// answers 403 forbidden. A malformed `limit` or `cursor` answers 400 validation_failed.
|
||||
//
|
||||
// GET /api/v1/me/privacy/history
|
||||
func (UnimplementedHandler) ListMyPrivacyHistory(ctx context.Context, params ListMyPrivacyHistoryParams) (r ListMyPrivacyHistoryRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// ListMySupportCases implements ListMySupportCases operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate or an employer account. Returns a page of the cases that
|
||||
@@ -1311,6 +1467,96 @@ func (UnimplementedHandler) SendOrganizationInvitation(ctx context.Context, req
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SetMyPublication implements SetMyPublication operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new publication setting: `state` `published` with
|
||||
// the non-empty set of card fields, or `closed` with an empty set. It changes only the publication;
|
||||
// the search status and the hidden organizations stay as they were.
|
||||
//
|
||||
// Publication is not a consent and does not duplicate one. The consent C2 lives in the consent ledger
|
||||
// (`ListMyConsents`); this setting refers to it. Publishing requires an active, unrevoked C2 record of
|
||||
// the account and binds the publication to that record, so a client sends no consent identifier and
|
||||
// cannot forge one. Without one the server answers 409 state_conflict with the entry
|
||||
// `{in: body, pointer: /state, code: consent_required}` in `errors`, which tells it apart from every
|
||||
// other conflict, and changes nothing: the client gives C2 first (planned in the consent settings,
|
||||
// TASK-063) and then publishes. The server takes the C2 record under a share lock in the transaction
|
||||
// that writes the publication, so a revocation that races with a publication either commits first (the
|
||||
// publication is refused) or closes the card right after. A revocation of C2 closes the card at once,
|
||||
// because `state` is computed from the unrevoked record; a later C2 grant never reopens it, and the
|
||||
// candidate publishes again under the new record. The revocation path itself (TASK-064) closes the
|
||||
// stored publication and revokes the contact grants in its own transaction. A closing sent over a
|
||||
// stored publication whose C2 was revoked is a real change: it stores the closing, records
|
||||
// `publication_closed`, and revokes the grants as any closing does. Publishing, like every visibility
|
||||
// change, needs a verified email (a usecase requirement; the unverified account cleanup deletes only
|
||||
// accounts without such records). Publishing never adds a field that the body did not name, and a new
|
||||
// `CardField` value is never published for a candidate who did not choose it.
|
||||
//
|
||||
// The field set contains only the groups of `CardField`. The full name, contacts, and the lowest
|
||||
// salary have no value there, so no body can publish them. Only values that the candidate confirmed
|
||||
// ever reach the card. Contacts reach an organization only through the contact grant (C4), and a
|
||||
// profile that is published or closed changes none of the grants that exist; closing the publication,
|
||||
// and hiding an organization that holds a grant, revoke the contact grants concerned with the reason
|
||||
// `visibility_closed` in the same transaction as the change (planned together with the operations, see
|
||||
// the invitation contract).
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body: the client sends the `version` it read,
|
||||
// 0 for the first publication. If it is not the current version the server answers 412
|
||||
// version_conflict and changes nothing. The version travels in the body rather than in If-Match
|
||||
// because the generated client cannot read the ETag header yet. A body that equals the stored setting
|
||||
// changes nothing, keeps the version, and answers 200 even when `expected_version` is older, so a
|
||||
// retry after a lost response succeeds without an Idempotency-Key. A version above the current one
|
||||
// never existed and always answers 412. Every change is recorded in the settings history with its
|
||||
// time, the fields, and the C2 record.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), rules that
|
||||
// depend on the body alone (400), an unchanged body (200), a stale version (412), then the active C2
|
||||
// for a publication (409 state_conflict). The schema rejects an unknown field, a repeated or unknown
|
||||
// card field, and more fields than there are groups; a published state with no field, and a closed
|
||||
// state with a field, answer 400 validation_failed with the pointer `/fields`. Error bodies never
|
||||
// repeat a submitted value.
|
||||
//
|
||||
// PUT /api/v1/me/privacy/publication
|
||||
func (UnimplementedHandler) SetMyPublication(ctx context.Context, req *PublicationUpdate) (r SetMyPublicationRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SetMySearchStatus implements SetMySearchStatus operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. The body is the complete new status: `looking` ("Ищу") or `not_looking`.
|
||||
// The status is a statement of the candidate and never a consent. It changes neither the C2 consent,
|
||||
// nor the publication, nor the hidden organizations, and it does not close or open any contact grant;
|
||||
// a candidate whose profile is closed who sets `looking` becomes visible to no one.
|
||||
//
|
||||
// `looking` stores the moment of the confirmation and a lapse time. The server takes the interval from
|
||||
// the `search_status` section of the effective product policy (30 days in the demo policy,
|
||||
// `searching_confirmation_interval_days`), stores the policy version it used, and fixes the lapse time
|
||||
// then, so a later policy change moves no stored time. Setting `looking` again is the confirmation: it
|
||||
// replaces the confirmation time with now and advances the version, also after a lapse. The body
|
||||
// carries no time, interval, or policy version.
|
||||
//
|
||||
// After the lapse time the status holds as `not_looking` with `lapsed` true on the next read. The
|
||||
// lapse is computed and written nowhere, so it needs no job, it can never make the candidate more
|
||||
// visible, and it never touches the publication or the hidden organizations. A reminder before the
|
||||
// lapse is a planned notification, not a part of this operation.
|
||||
//
|
||||
// Optimistic concurrency uses `expected_version` in the body, 0 for a candidate who never set the
|
||||
// status; a stale or non-existent version answers 412 version_conflict and changes nothing.
|
||||
// `not_looking` over a stored `not_looking` changes nothing and answers 200 even with a stale version.
|
||||
// `looking` always changes the stored confirmation, so a retry of a confirmation whose response was
|
||||
// lost with the old version answers 412 and the client reads the status again.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation (400),
|
||||
// account scenario (403 forbidden for an employer), a version above the current one (412), an
|
||||
// unchanged `not_looking` (200), then a stale version (412).
|
||||
//
|
||||
// PUT /api/v1/me/privacy/search-status
|
||||
func (UnimplementedHandler) SetMySearchStatus(ctx context.Context, req *SearchStatusUpdate) (r SetMySearchStatusRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// SubmitMyAssessmentAnswer implements SubmitMyAssessmentAnswer operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
@@ -1371,6 +1617,27 @@ func (UnimplementedHandler) SubmitMyAssessmentAnswer(ctx context.Context, req *A
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UnhideOrganization implements UnhideOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of a candidate account, the CSRF token of that session in X-CSRF-Token,
|
||||
// and an allowed Origin. Deletes the hiding record of the candidate for the organization in the path.
|
||||
// The request is idempotent: it answers 204 whether the organization was hidden, was not hidden, or
|
||||
// does not exist, so the operation reveals nothing about the organization, and a repeat after a lost
|
||||
// response succeeds. The record is deleted, the settings history keeps the event
|
||||
// `organization_unhidden` only when a record was deleted.
|
||||
//
|
||||
// Lifting the hiding makes the candidate readable by that organization again only if the profile is
|
||||
// published and the organization otherwise may read it. It changes neither the C2 consent, nor the
|
||||
// publication, nor the search status, and it never reopens a contact grant that the hiding closed.
|
||||
//
|
||||
// Order of checks: session (401), CSRF and Origin (403 csrf_check_failed), request validation of the
|
||||
// path (400), account scenario (403 forbidden for an employer), then the deletion (204).
|
||||
//
|
||||
// DELETE /api/v1/me/privacy/hidden-organizations/{org_id}
|
||||
func (UnimplementedHandler) UnhideOrganization(ctx context.Context, params UnhideOrganizationParams) (r UnhideOrganizationRes, _ error) {
|
||||
return r, ht.ErrNotImplemented
|
||||
}
|
||||
|
||||
// UpdateOrganization implements UpdateOrganization operation.
|
||||
//
|
||||
// Requires the session cookie of an employer account with an active membership in `org_id`, the CSRF
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,408 @@
|
||||
package httpadapter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ogen-go/ogen"
|
||||
|
||||
"lincodex/backend/internal/adapter/primary/http/api"
|
||||
"lincodex/backend/internal/adapter/primary/http/problem"
|
||||
v1 "lincodex/backend/internal/adapter/primary/http/v1"
|
||||
metrics "lincodex/backend/internal/adapter/secondary/prometheus"
|
||||
)
|
||||
|
||||
const (
|
||||
privacyBasePath = "/api/v1/me/privacy"
|
||||
privacyPublicationPath = privacyBasePath + "/publication"
|
||||
privacySearchStatusPath = privacyBasePath + "/search-status"
|
||||
privacyHiddenPath = privacyBasePath + "/hidden-organizations"
|
||||
privacyOrganizationID = "01928f7a-1a2b-7c3d-8e4f-5a6b7c8d9e01"
|
||||
)
|
||||
|
||||
// Each visibility setting is its own family of schemas. The three never
|
||||
// refer to one another, so a client cannot read or write one setting through
|
||||
// the DTO of another, and the search status is not a consent.
|
||||
var (
|
||||
publicationSchemas = []string{"Publication", "PublicationUpdate", "PublicationVersion", "PublicationState", "PublicationClosedReason", "CardField", "CardFieldSet"}
|
||||
searchStatusSchemas = []string{"SearchStatus", "SearchStatusUpdate", "SearchStatusVersion", "SearchStatusValue"}
|
||||
hiddenSchemas = []string{"HiddenOrganization", "HiddenOrganizationList", "PrivacyOrganization"}
|
||||
privacyOnlySchemas = []string{"PrivacySettings", "CardPreview", "AnonymousCardContent", "CardCategory", "PrivacyEvent", "PrivacyEventKind", "PrivacyEventList", "CardAccess", "CardAccessKind", "CardAccessList"}
|
||||
// sharedLeafSchemas are the reusable leaves that the privacy family may
|
||||
// refer to; none of them identifies a person or carries a contact.
|
||||
sharedLeafSchemas = []string{"Timestamp", "PageInfo", "SpecializationCode", "GradeCode", "StackTag"}
|
||||
)
|
||||
|
||||
func isPrivacySchema(name string) bool {
|
||||
return slices.Contains(publicationSchemas, name) || slices.Contains(searchStatusSchemas, name) ||
|
||||
slices.Contains(hiddenSchemas, name) || slices.Contains(privacyOnlySchemas, name)
|
||||
}
|
||||
|
||||
// parameterName names a parameter by its component when it is a reference.
|
||||
func parameterName(parameter *ogen.Parameter) string {
|
||||
if parameter.Ref != "" {
|
||||
return parameter.Ref[strings.LastIndex(parameter.Ref, "/")+1:]
|
||||
}
|
||||
return parameter.Name
|
||||
}
|
||||
|
||||
func privacyOperations(t *testing.T, spec *ogen.Spec) []*ogen.Operation {
|
||||
t.Helper()
|
||||
operations := make([]*ogen.Operation, 0, 9)
|
||||
for _, id := range []string{
|
||||
"GetMyPrivacySettings", "SetMyPublication", "GetMyCardPreview", "SetMySearchStatus", "ListMyHiddenOrganizations",
|
||||
"HideOrganization", "UnhideOrganization", "ListMyPrivacyHistory", "ListMyCardAccessHistory",
|
||||
} {
|
||||
operations = append(operations, operationByID(t, spec, id))
|
||||
}
|
||||
return operations
|
||||
}
|
||||
|
||||
// Every visibility operation follows the project conventions: the session
|
||||
// only for reads, the session and the CSRF token for changes, the version in
|
||||
// the body with 412, 409 for a state that does not allow the change, 404
|
||||
// without a distinction, and no new problem code.
|
||||
func TestPrivacyOperationsFollowTheConventions(t *testing.T) {
|
||||
spec := parsePublicContract(t)
|
||||
unsafe := map[string]bool{"SetMyPublication": true, "SetMySearchStatus": true, "HideOrganization": true, "UnhideOrganization": true}
|
||||
for _, operation := range privacyOperations(t, spec) {
|
||||
if !slices.Contains(operation.Tags, "privacy") {
|
||||
t.Errorf("%s is not in the privacy tag", operation.OperationID)
|
||||
}
|
||||
if !hasSecurity(operation, "sessionCookie") || hasSecurity(operation, "sessionCsrf") != unsafe[operation.OperationID] {
|
||||
t.Errorf("%s security = %v, want the session cookie, and the CSRF token exactly for a change", operation.OperationID, operation.Security)
|
||||
}
|
||||
for _, status := range []string{"401", "403"} {
|
||||
if operation.Responses[status] == nil {
|
||||
t.Errorf("%s does not declare %s", operation.OperationID, status)
|
||||
}
|
||||
}
|
||||
for _, parameter := range operation.Parameters {
|
||||
name := parameterName(parameter)
|
||||
if strings.EqualFold(name, "IdempotencyKey") || strings.EqualFold(name, "IfMatch") || strings.EqualFold(name, "Idempotency-Key") || strings.EqualFold(name, "If-Match") {
|
||||
t.Errorf("%s takes %s, but every setting is a replaced state with its version in the body", operation.OperationID, name)
|
||||
}
|
||||
}
|
||||
if success := operation.Responses["200"]; success != nil && success.Headers["Cache-Control"] == nil {
|
||||
t.Errorf("%s does not mark its 200 response no-store", operation.OperationID)
|
||||
}
|
||||
if operation.Responses["default"] == nil {
|
||||
t.Errorf("%s does not declare the problem default", operation.OperationID)
|
||||
}
|
||||
}
|
||||
for _, id := range []string{"SetMyPublication", "SetMySearchStatus"} {
|
||||
operation := operationByID(t, spec, id)
|
||||
if operation.Responses["412"] == nil || operation.Responses["400"] == nil {
|
||||
t.Errorf("%s does not declare 400 and 412", id)
|
||||
}
|
||||
update := resolveSchema(t, spec, operation.RequestBody.Content["application/json"].Schema)
|
||||
if !slices.Contains(update.Required, "expected_version") {
|
||||
t.Errorf("%s does not require expected_version", id)
|
||||
}
|
||||
}
|
||||
// Publishing needs the C2 consent, and a missing one is a state conflict.
|
||||
if operationByID(t, spec, "SetMyPublication").Responses["409"] == nil {
|
||||
t.Error("SetMyPublication does not declare 409 state_conflict for a missing C2 consent")
|
||||
}
|
||||
if operationByID(t, spec, "SetMySearchStatus").Responses["409"] != nil {
|
||||
t.Error("SetMySearchStatus declares 409: the status never depends on a consent")
|
||||
}
|
||||
// Hiding uses the same 404 for an unknown organization and one the
|
||||
// candidate cannot see; lifting the hiding reveals nothing and has no 404.
|
||||
hide := operationByID(t, spec, "HideOrganization")
|
||||
if hide.Responses["404"] == nil || hide.Responses["409"] == nil || hide.Responses["429"] == nil || hide.RequestBody != nil {
|
||||
t.Error("HideOrganization must declare 404, 409, and 429 and take no body")
|
||||
}
|
||||
unhide := operationByID(t, spec, "UnhideOrganization")
|
||||
if unhide.Responses["204"] == nil || unhide.Responses["404"] != nil {
|
||||
t.Error("UnhideOrganization must answer 204 and declare no 404: it reveals nothing about the organization")
|
||||
}
|
||||
// Lists page with the shared cursor parameters.
|
||||
for _, id := range []string{"ListMyHiddenOrganizations", "ListMyPrivacyHistory", "ListMyCardAccessHistory"} {
|
||||
names := []string{}
|
||||
for _, parameter := range operationByID(t, spec, id).Parameters {
|
||||
names = append(names, parameterName(parameter))
|
||||
}
|
||||
if !slices.Contains(names, "PageLimit") || !slices.Contains(names, "PageCursor") {
|
||||
t.Errorf("%s parameters = %v, want the shared PageLimit and PageCursor", id, names)
|
||||
}
|
||||
}
|
||||
|
||||
// No new problem code: every code of the privacy responses already exists.
|
||||
codes := enumValues(t, resolveSchema(t, spec, &ogen.Schema{Ref: "#/components/schemas/ProblemCode"}))
|
||||
for _, code := range []string{"state_conflict", "version_conflict", "not_found", "rate_limited", "validation_failed"} {
|
||||
if !slices.Contains(codes, code) {
|
||||
t.Errorf("ProblemCode has no %s", code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The publication stores which fields are published and refers to the C2
|
||||
// consent of the ledger; it neither carries nor changes a consent. The search
|
||||
// status is not a consent either.
|
||||
func TestPublicationAndSearchStatusAreNotConsents(t *testing.T) {
|
||||
spec := parsePublicContract(t)
|
||||
index := componentsIndex(t, spec)
|
||||
|
||||
for _, pair := range []struct {
|
||||
name string
|
||||
want []string
|
||||
}{
|
||||
// The body names no consent: the server binds the active C2 record.
|
||||
{"PublicationUpdate", []string{"expected_version", "fields", "state"}},
|
||||
{"SearchStatusUpdate", []string{"expected_version", "value"}},
|
||||
{"Publication", []string{"closed_reason", "consent_id", "fields", "published_at", "state", "version"}},
|
||||
{"SearchStatus", []string{"confirmed_at", "lapsed", "lapses_at", "value", "version"}},
|
||||
{"HiddenOrganization", []string{"hidden_at", "organization"}},
|
||||
{"PrivacySettings", []string{"hidden_organizations_total", "publication", "search_status"}},
|
||||
} {
|
||||
schema := spec.Components.Schemas[pair.name]
|
||||
if schema == nil {
|
||||
t.Fatalf("the contract has no schema %s", pair.name)
|
||||
}
|
||||
if got := propertyNames(schema); !slices.Equal(got, pair.want) {
|
||||
t.Errorf("%s properties = %v, want %v", pair.name, got, pair.want)
|
||||
}
|
||||
if schema.AdditionalProperties.Bool == nil || *schema.AdditionalProperties.Bool {
|
||||
t.Errorf("%s accepts unknown fields", pair.name)
|
||||
}
|
||||
}
|
||||
|
||||
// The families do not reach one another. PrivacySettings is the one place
|
||||
// that reads the three together.
|
||||
families := map[string][]string{"publication": publicationSchemas, "search status": searchStatusSchemas, "hidden organizations": hiddenSchemas}
|
||||
for name, members := range families {
|
||||
for _, member := range members {
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, spec.Components.Schemas[member])) {
|
||||
for otherName, others := range families {
|
||||
if otherName != name && slices.Contains(others, reached) {
|
||||
t.Errorf("the %s schema %s reaches the %s schema %s", name, member, otherName, reached)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A consent, a profile, an account, or an invitation is reachable from
|
||||
// none of the settings: the status is a statement, never a consent.
|
||||
for _, name := range slices.Concat(publicationSchemas, searchStatusSchemas, hiddenSchemas, privacyOnlySchemas) {
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, spec.Components.Schemas[name])) {
|
||||
if strings.HasPrefix(reached, "Consent") || strings.HasPrefix(reached, "Profile") || strings.HasPrefix(reached, "CandidateProfile") ||
|
||||
strings.HasPrefix(reached, "Invitation") || strings.HasPrefix(reached, "Contact") || reached == "Session" || reached == "User" {
|
||||
t.Errorf("%s reaches %s", name, reached)
|
||||
}
|
||||
}
|
||||
}
|
||||
// The search status operation reaches no publication or hidden schema.
|
||||
statusOperation := reachableSchemas(index, mustJSONValue(t, spec.Paths[privacySearchStatusPath]))
|
||||
for _, name := range slices.Concat(publicationSchemas, hiddenSchemas, privacyOnlySchemas) {
|
||||
if statusOperation[name] {
|
||||
t.Errorf("the search status path reaches %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
// The published field set cannot name a name, a contact, or the salary.
|
||||
fields := enumValues(t, resolveSchema(t, spec, &ogen.Schema{Ref: "#/components/schemas/CardField"}))
|
||||
want := []string{"categories", "stack", "experience", "soft_skills", "location", "relocation"}
|
||||
slices.Sort(fields)
|
||||
slices.Sort(want)
|
||||
if !slices.Equal(fields, want) {
|
||||
t.Errorf("CardField = %v, want %v", fields, want)
|
||||
}
|
||||
if update := spec.Components.Schemas["CardFieldSet"]; update.UniqueItems != true || update.MaxItems == nil || *update.MaxItems != uint64(len(want)) {
|
||||
t.Error("CardFieldSet must hold distinct items and at most one per field")
|
||||
}
|
||||
status := enumValues(t, resolveSchema(t, spec, &ogen.Schema{Ref: "#/components/schemas/SearchStatusValue"}))
|
||||
if !slices.Equal(status, []string{"looking", "not_looking"}) {
|
||||
t.Errorf("SearchStatusValue = %v, want looking and not_looking", status)
|
||||
}
|
||||
}
|
||||
|
||||
// The anonymous card never reaches a profile, a contact, or an identifier:
|
||||
// whatever an organization reads of a candidate before an accepted invitation
|
||||
// is limited to its own closed set of properties.
|
||||
func TestAnonymousCardReachesNoProfileOrContactSchema(t *testing.T) {
|
||||
spec := parsePublicContract(t)
|
||||
index := componentsIndex(t, spec)
|
||||
|
||||
card := spec.Components.Schemas["AnonymousCardContent"]
|
||||
if card == nil {
|
||||
t.Fatal("the contract has no AnonymousCardContent")
|
||||
}
|
||||
if got, want := propertyNames(card), []string{"categories", "experience_months", "location", "relocation", "soft_skills", "stack"}; !slices.Equal(got, want) {
|
||||
t.Errorf("AnonymousCardContent properties = %v, want %v", got, want)
|
||||
}
|
||||
if card.AdditionalProperties.Bool == nil || *card.AdditionalProperties.Bool {
|
||||
t.Error("AnonymousCardContent accepts unknown properties")
|
||||
}
|
||||
// Each property is a card field and nothing else; a null is a hidden or
|
||||
// missing value, never a flag that tells which.
|
||||
for _, forbidden := range []string{"email", "phone", "telegram", "contact", "name", "salary", "user", "account", "profile", "employer", "id", "url", "link", "github", "resume"} {
|
||||
for _, name := range propertyNames(card) {
|
||||
if strings.Contains(name, forbidden) {
|
||||
t.Errorf("AnonymousCardContent has the property %q, which looks like %q", name, forbidden)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// What the card and the preview reach is a small closed list of leaves.
|
||||
allowed := []string{"AnonymousCardContent", "CardCategory", "CardField", "CardFieldSet", "PublicationState", "SpecializationCode", "GradeCode", "StackTag", "Timestamp", "CardPreview"}
|
||||
for _, name := range []string{"AnonymousCardContent", "CardPreview"} {
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, spec.Components.Schemas[name])) {
|
||||
if !slices.Contains(allowed, reached) {
|
||||
t.Errorf("%s reaches %s, which the anonymous card must not carry", name, reached)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The private profile, the contact formats, and the contact disclosure
|
||||
// are not reachable from any privacy schema or operation.
|
||||
for path, item := range spec.Paths {
|
||||
if !strings.HasPrefix(path, privacyBasePath) {
|
||||
continue
|
||||
}
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, item)) {
|
||||
if isProfileSchema(reached) || strings.HasPrefix(reached, "Contact") || reached == "EmailAddress" || reached == "PhoneNumber" ||
|
||||
strings.HasPrefix(reached, "Invitation") || strings.HasPrefix(reached, "Need") || strings.HasPrefix(reached, "Consent") {
|
||||
t.Errorf("%s reaches %s", path, reached)
|
||||
}
|
||||
if !isPrivacySchema(reached) && !slices.Contains(sharedLeafSchemas, reached) && !strings.HasPrefix(reached, "Problem") &&
|
||||
reached != "Problem" && reached != "ProblemCode" {
|
||||
t.Errorf("%s reaches %s, which is neither a privacy schema nor a shared leaf", path, reached)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The reverse: the private profile family does not reach the card or any
|
||||
// visibility schema, and an organization path reaches no setting of a
|
||||
// candidate. The card content stays the only privacy schema meant for
|
||||
// organization-visible operations later (TASK-185).
|
||||
for name, schema := range spec.Components.Schemas {
|
||||
if isPrivacySchema(name) {
|
||||
continue
|
||||
}
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, schema)) {
|
||||
if isPrivacySchema(reached) && reached != "AnonymousCardContent" && reached != "CardCategory" && reached != "CardField" && reached != "CardFieldSet" {
|
||||
t.Errorf("%s reaches the candidate-private schema %s", name, reached)
|
||||
}
|
||||
}
|
||||
}
|
||||
for path, item := range spec.Paths {
|
||||
if !strings.HasPrefix(path, "/api/v1/organizations") {
|
||||
continue
|
||||
}
|
||||
for reached := range reachableSchemas(index, mustJSONValue(t, item)) {
|
||||
if isPrivacySchema(reached) {
|
||||
t.Errorf("%s reaches the candidate-private schema %s", path, reached)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, dto := range []any{api.AnonymousCardContent{}, api.CardCategory{}, api.CardPreview{}} {
|
||||
assertNoJSONFields(t, dto, []string{
|
||||
"full_name", "name", "email", "phone", "telegram", "contacts", "salary_minimum", "user_id", "account_id", "profile_id", "employer", "resume",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// The generated request DTOs carry only what the candidate may choose: no
|
||||
// consent identifier, time, interval, or policy version.
|
||||
func TestGeneratedPrivacyDTOsCarryNoServerOwnedFields(t *testing.T) {
|
||||
assertNoJSONFields(t, api.PublicationUpdate{}, []string{"consent_id", "consent", "published_at", "version", "user_id", "contacts", "full_name", "salary_minimum"})
|
||||
assertNoJSONFields(t, api.SearchStatusUpdate{}, []string{"confirmed_at", "lapses_at", "lapsed", "interval", "policy_version", "policy_version_id", "consent_id", "version"})
|
||||
assertNoJSONFields(t, api.SearchStatus{}, []string{"consent_id", "published", "fields", "hidden_organizations", "policy_version_id"})
|
||||
assertNoJSONFields(t, api.HiddenOrganization{}, []string{"user_id", "candidate_id", "candidate", "reason"})
|
||||
}
|
||||
|
||||
func newPrivacyRouter(t *testing.T) http.Handler {
|
||||
t.Helper()
|
||||
logger := slog.New(slog.DiscardHandler)
|
||||
healthHandler := newTestHealthHandler(func(context.Context) error { return nil })
|
||||
router, err := NewRouter(healthHandler, v1.NewHandler(healthHandler, problem.NewResponder(logger)), &recordingSecurity{}, problem.NewResponder(logger), metrics.New(), logger, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("NewRouter() error = %v", err)
|
||||
}
|
||||
return router
|
||||
}
|
||||
|
||||
// The operations are in the contract before their business logic: a schema
|
||||
// failure answers 400 before anything else, a valid request with an accepted
|
||||
// session answers 501, and no body reaches the handler without validation.
|
||||
func TestPrivacySchemaValidationPrecedesImplementation(t *testing.T) {
|
||||
session := map[string]string{"Cookie": testSessionCookie, "X-CSRF-Token": testCSRFToken}
|
||||
for _, test := range []struct {
|
||||
name string
|
||||
method string
|
||||
path string
|
||||
body string
|
||||
statusCode int
|
||||
location api.ProblemFieldLocation
|
||||
pointer string
|
||||
code string
|
||||
}{
|
||||
{name: "a valid publication", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"published","fields":["categories","stack"]}`, statusCode: http.StatusNotImplemented},
|
||||
{name: "a valid closing", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":3,"state":"closed","fields":[]}`, statusCode: http.StatusNotImplemented},
|
||||
{name: "a missing version", method: http.MethodPut, path: privacyPublicationPath, body: `{"state":"closed","fields":[]}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/expected_version", code: "required"},
|
||||
{name: "a negative version", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":-1,"state":"closed","fields":[]}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/expected_version", code: "invalid"},
|
||||
{name: "a contact as a card field", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"published","fields":["phone"]}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/fields/0", code: "invalid"},
|
||||
{name: "the full name as a card field", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"published","fields":["full_name"]}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/fields/0", code: "invalid"},
|
||||
{name: "a repeated card field", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"published","fields":["stack","stack"]}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/fields", code: "invalid"},
|
||||
{name: "a state outside the enum", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"draft","fields":[]}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/state", code: "invalid"},
|
||||
{name: "a consent identifier from the client", method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"published","fields":["stack"],"consent_id":"01928f7a-7a8b-7c9d-8e0f-1a2b3c4d5e60"}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "", code: "invalid"},
|
||||
{name: "a valid status", method: http.MethodPut, path: privacySearchStatusPath, body: `{"expected_version":0,"value":"looking"}`, statusCode: http.StatusNotImplemented},
|
||||
{name: "a status outside the enum", method: http.MethodPut, path: privacySearchStatusPath, body: `{"expected_version":0,"value":"open"}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "/value", code: "invalid"},
|
||||
{name: "a confirmation time from the client", method: http.MethodPut, path: privacySearchStatusPath, body: `{"expected_version":0,"value":"looking","confirmed_at":"2026-10-06T09:00:00Z"}`, statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationBody, pointer: "", code: "invalid"},
|
||||
{name: "hiding an organization", method: http.MethodPut, path: privacyHiddenPath + "/" + privacyOrganizationID, statusCode: http.StatusNotImplemented},
|
||||
{name: "hiding a malformed identifier", method: http.MethodPut, path: privacyHiddenPath + "/not-a-uuid", statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationPath, pointer: "/org_id", code: "invalid"},
|
||||
{name: "lifting a hiding", method: http.MethodDelete, path: privacyHiddenPath + "/" + privacyOrganizationID, statusCode: http.StatusNotImplemented},
|
||||
{name: "lifting a malformed identifier", method: http.MethodDelete, path: privacyHiddenPath + "/not-a-uuid", statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationPath, pointer: "/org_id", code: "invalid"},
|
||||
{name: "the settings", method: http.MethodGet, path: privacyBasePath, statusCode: http.StatusNotImplemented},
|
||||
{name: "the preview", method: http.MethodGet, path: privacyBasePath + "/preview", statusCode: http.StatusNotImplemented},
|
||||
{name: "the hidden list", method: http.MethodGet, path: privacyHiddenPath + "?limit=50", statusCode: http.StatusNotImplemented},
|
||||
{name: "a hidden list limit over 100", method: http.MethodGet, path: privacyHiddenPath + "?limit=101", statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationQuery, pointer: "/limit", code: "invalid"},
|
||||
{name: "the history", method: http.MethodGet, path: privacyBasePath + "/history", statusCode: http.StatusNotImplemented},
|
||||
{name: "a malformed history cursor", method: http.MethodGet, path: privacyBasePath + "/history?cursor=not%20a%20cursor", statusCode: http.StatusBadRequest, location: api.ProblemFieldLocationQuery, pointer: "/cursor", code: "invalid"},
|
||||
{name: "the access history", method: http.MethodGet, path: privacyBasePath + "/access-history", statusCode: http.StatusNotImplemented},
|
||||
} {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
response := serveIdentityRequest(t, newPrivacyRouter(t), identityRequest{method: test.method, path: test.path, body: test.body, headers: session})
|
||||
if test.statusCode == http.StatusNotImplemented {
|
||||
requireProblem(t, response, http.StatusNotImplemented, api.ProblemCodeNotImplemented)
|
||||
return
|
||||
}
|
||||
problemBody := requireProblem(t, response, test.statusCode, api.ProblemCodeValidationFailed)
|
||||
want := api.ProblemFieldError{In: test.location, Pointer: test.pointer, Code: test.code}
|
||||
for _, field := range problemBody.Errors {
|
||||
if field.In == want.In && field.Pointer == want.Pointer && field.Code == want.Code {
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fatalf("errors = %+v, want an entry %+v", problemBody.Errors, want)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Nothing here is reachable without a session: the deny-all security of the
|
||||
// scaffold answers 401 for every operation, with or without a cookie.
|
||||
func TestPrivacyAccessBeforeImplementation(t *testing.T) {
|
||||
session := map[string]string{"Cookie": testSessionCookie, "X-CSRF-Token": testCSRFToken}
|
||||
for _, test := range []identityRequest{
|
||||
{method: http.MethodGet, path: privacyBasePath},
|
||||
{method: http.MethodGet, path: privacyBasePath + "/preview"},
|
||||
{method: http.MethodGet, path: privacyBasePath + "/history", headers: session},
|
||||
{method: http.MethodGet, path: privacyBasePath + "/access-history"},
|
||||
{method: http.MethodGet, path: privacyHiddenPath},
|
||||
{method: http.MethodPut, path: privacyPublicationPath, body: `{"expected_version":0,"state":"closed","fields":[]}`, headers: session},
|
||||
{method: http.MethodPut, path: privacySearchStatusPath, body: `{"expected_version":0,"value":"not_looking"}`, headers: session},
|
||||
{method: http.MethodPut, path: privacyHiddenPath + "/" + privacyOrganizationID, headers: session},
|
||||
{method: http.MethodDelete, path: privacyHiddenPath + "/" + privacyOrganizationID, headers: session},
|
||||
} {
|
||||
t.Run(test.method+" "+test.path, func(t *testing.T) {
|
||||
router := newTestRouter(t, func(context.Context) error { return nil })
|
||||
requireProblem(t, serveIdentityRequest(t, router, test), http.StatusUnauthorized, api.ProblemCodeUnauthenticated)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,30 @@ type AssessmentFamily struct {
|
||||
RetiredBy pgtype.Text
|
||||
}
|
||||
|
||||
type CandidateEffectivePublication struct {
|
||||
UserID pgtype.UUID
|
||||
Fields []string
|
||||
PublishedAt pgtype.Timestamptz
|
||||
Version int64
|
||||
}
|
||||
|
||||
type CandidateHiddenOrganization struct {
|
||||
UserID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
HiddenAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type CandidatePrivacyEvent struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
Kind string
|
||||
OccurredAt pgtype.Timestamptz
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
ConsentPurpose pgtype.Text
|
||||
OrganizationID pgtype.UUID
|
||||
}
|
||||
|
||||
type CandidateProfile struct {
|
||||
UserID pgtype.UUID
|
||||
Version int64
|
||||
@@ -62,6 +86,30 @@ type CandidateProfileClaim struct {
|
||||
ConfirmedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type CandidatePublication struct {
|
||||
UserID pgtype.UUID
|
||||
State string
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
ConsentPurpose pgtype.Text
|
||||
PublishedAt pgtype.Timestamptz
|
||||
ClosedAt pgtype.Timestamptz
|
||||
Version int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type CandidateSearchStatus struct {
|
||||
UserID pgtype.UUID
|
||||
Status string
|
||||
ConfirmedAt pgtype.Timestamptz
|
||||
LapsesAt pgtype.Timestamptz
|
||||
PolicyVersionID pgtype.UUID
|
||||
Version int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type ConsentRecord struct {
|
||||
ID pgtype.UUID
|
||||
SubjectID pgtype.UUID
|
||||
|
||||
@@ -0,0 +1,683 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: privacy.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const countCandidateHiddenOrganizations = `-- name: CountCandidateHiddenOrganizations :one
|
||||
SELECT count(*) AS total
|
||||
FROM candidate_hidden_organizations
|
||||
WHERE user_id = $1
|
||||
`
|
||||
|
||||
// Counts the hiding records of one candidate for the settings read.
|
||||
func (q *Queries) CountCandidateHiddenOrganizations(ctx context.Context, userID pgtype.UUID) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countCandidateHiddenOrganizations, userID)
|
||||
var total int64
|
||||
err := row.Scan(&total)
|
||||
return total, err
|
||||
}
|
||||
|
||||
const deleteCandidateHiddenOrganization = `-- name: DeleteCandidateHiddenOrganization :one
|
||||
DELETE FROM candidate_hidden_organizations
|
||||
WHERE user_id = $1 AND organization_id = $2
|
||||
RETURNING organization_id
|
||||
`
|
||||
|
||||
type DeleteCandidateHiddenOrganizationParams struct {
|
||||
UserID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
}
|
||||
|
||||
// Lifts one hiding. No row returns when the organization was not hidden, so
|
||||
// the caller writes the history event only for a real deletion and answers
|
||||
// 204 either way.
|
||||
func (q *Queries) DeleteCandidateHiddenOrganization(ctx context.Context, arg DeleteCandidateHiddenOrganizationParams) (pgtype.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, deleteCandidateHiddenOrganization, arg.UserID, arg.OrganizationID)
|
||||
var organization_id pgtype.UUID
|
||||
err := row.Scan(&organization_id)
|
||||
return organization_id, err
|
||||
}
|
||||
|
||||
const getCandidateHiddenOrganization = `-- name: GetCandidateHiddenOrganization :one
|
||||
SELECT
|
||||
candidate_hidden_organizations.organization_id,
|
||||
organizations.name AS organization_name,
|
||||
candidate_hidden_organizations.hidden_at
|
||||
FROM candidate_hidden_organizations
|
||||
INNER JOIN organizations
|
||||
ON organizations.id = candidate_hidden_organizations.organization_id
|
||||
WHERE
|
||||
candidate_hidden_organizations.user_id = $1
|
||||
AND candidate_hidden_organizations.organization_id = $2
|
||||
`
|
||||
|
||||
type GetCandidateHiddenOrganizationParams struct {
|
||||
UserID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
}
|
||||
|
||||
type GetCandidateHiddenOrganizationRow struct {
|
||||
OrganizationID pgtype.UUID
|
||||
OrganizationName string
|
||||
HiddenAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Reads one hiding of the candidate with the current name of the
|
||||
// organization.
|
||||
func (q *Queries) GetCandidateHiddenOrganization(ctx context.Context, arg GetCandidateHiddenOrganizationParams) (GetCandidateHiddenOrganizationRow, error) {
|
||||
row := q.db.QueryRow(ctx, getCandidateHiddenOrganization, arg.UserID, arg.OrganizationID)
|
||||
var i GetCandidateHiddenOrganizationRow
|
||||
err := row.Scan(&i.OrganizationID, &i.OrganizationName, &i.HiddenAt)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertCandidateHiddenOrganization = `-- name: InsertCandidateHiddenOrganization :one
|
||||
INSERT INTO candidate_hidden_organizations (
|
||||
user_id,
|
||||
organization_id,
|
||||
hidden_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3
|
||||
)
|
||||
ON CONFLICT (user_id, organization_id) DO NOTHING
|
||||
RETURNING user_id, organization_id, hidden_at
|
||||
`
|
||||
|
||||
type InsertCandidateHiddenOrganizationParams struct {
|
||||
UserID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
At pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Hides one organization. No row returns when the pair already exists, and
|
||||
// the caller reads the existing record with its original time. The foreign key
|
||||
// refuses an unknown organization (SQLSTATE 23503); the caller answers it
|
||||
// exactly like an organization the candidate cannot see. The trigger refuses
|
||||
// the 1001st record (candidate_hidden_organizations_limit). The trigger runs
|
||||
// before the conflict check, so the caller reads the existing record first
|
||||
// and a repeat at the limit is never refused.
|
||||
func (q *Queries) InsertCandidateHiddenOrganization(ctx context.Context, arg InsertCandidateHiddenOrganizationParams) (CandidateHiddenOrganization, error) {
|
||||
row := q.db.QueryRow(ctx, insertCandidateHiddenOrganization, arg.UserID, arg.OrganizationID, arg.At)
|
||||
var i CandidateHiddenOrganization
|
||||
err := row.Scan(&i.UserID, &i.OrganizationID, &i.HiddenAt)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertCandidatePrivacyEvent = `-- name: InsertCandidatePrivacyEvent :exec
|
||||
INSERT INTO candidate_privacy_events (
|
||||
id,
|
||||
user_id,
|
||||
kind,
|
||||
occurred_at,
|
||||
fields,
|
||||
consent_record_id,
|
||||
organization_id
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7
|
||||
)
|
||||
`
|
||||
|
||||
type InsertCandidatePrivacyEventParams struct {
|
||||
ID pgtype.UUID
|
||||
UserID pgtype.UUID
|
||||
Kind string
|
||||
OccurredAt pgtype.Timestamptz
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
}
|
||||
|
||||
// Appends one event to the settings history. The row holds identifiers, card
|
||||
// field codes, and times, never a name; the caller
|
||||
// writes it in the transaction of the change it records.
|
||||
func (q *Queries) InsertCandidatePrivacyEvent(ctx context.Context, arg InsertCandidatePrivacyEventParams) error {
|
||||
_, err := q.db.Exec(ctx, insertCandidatePrivacyEvent,
|
||||
arg.ID,
|
||||
arg.UserID,
|
||||
arg.Kind,
|
||||
arg.OccurredAt,
|
||||
arg.Fields,
|
||||
arg.ConsentRecordID,
|
||||
arg.OrganizationID,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const insertCandidatePublication = `-- name: InsertCandidatePublication :one
|
||||
INSERT INTO candidate_publications (
|
||||
user_id,
|
||||
state,
|
||||
fields,
|
||||
consent_record_id,
|
||||
published_at,
|
||||
closed_at,
|
||||
version,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
1,
|
||||
$7,
|
||||
$7
|
||||
)
|
||||
ON CONFLICT (user_id) DO NOTHING
|
||||
RETURNING user_id, version
|
||||
`
|
||||
|
||||
type InsertCandidatePublicationParams struct {
|
||||
UserID pgtype.UUID
|
||||
State string
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
PublishedAt pgtype.Timestamptz
|
||||
ClosedAt pgtype.Timestamptz
|
||||
At pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type InsertCandidatePublicationRow struct {
|
||||
UserID pgtype.UUID
|
||||
Version int64
|
||||
}
|
||||
|
||||
// Stores the first publication at version 1. No row returns when the account
|
||||
// already has a row, so a first publication that lost a race with another
|
||||
// one is answered as a version conflict. The foreign key refuses a record
|
||||
// that is not a C2 record of this account.
|
||||
func (q *Queries) InsertCandidatePublication(ctx context.Context, arg InsertCandidatePublicationParams) (InsertCandidatePublicationRow, error) {
|
||||
row := q.db.QueryRow(ctx, insertCandidatePublication,
|
||||
arg.UserID,
|
||||
arg.State,
|
||||
arg.Fields,
|
||||
arg.ConsentRecordID,
|
||||
arg.PublishedAt,
|
||||
arg.ClosedAt,
|
||||
arg.At,
|
||||
)
|
||||
var i InsertCandidatePublicationRow
|
||||
err := row.Scan(&i.UserID, &i.Version)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertCandidateSearchStatus = `-- name: InsertCandidateSearchStatus :one
|
||||
INSERT INTO candidate_search_statuses (
|
||||
user_id,
|
||||
status,
|
||||
confirmed_at,
|
||||
lapses_at,
|
||||
policy_version_id,
|
||||
version,
|
||||
created_at,
|
||||
updated_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
1,
|
||||
$6,
|
||||
$6
|
||||
)
|
||||
ON CONFLICT (user_id) DO NOTHING
|
||||
RETURNING user_id, version
|
||||
`
|
||||
|
||||
type InsertCandidateSearchStatusParams struct {
|
||||
UserID pgtype.UUID
|
||||
Status string
|
||||
ConfirmedAt pgtype.Timestamptz
|
||||
LapsesAt pgtype.Timestamptz
|
||||
PolicyVersionID pgtype.UUID
|
||||
At pgtype.Timestamptz
|
||||
}
|
||||
|
||||
type InsertCandidateSearchStatusRow struct {
|
||||
UserID pgtype.UUID
|
||||
Version int64
|
||||
}
|
||||
|
||||
// Stores the first status at version 1; no row returns when one exists.
|
||||
func (q *Queries) InsertCandidateSearchStatus(ctx context.Context, arg InsertCandidateSearchStatusParams) (InsertCandidateSearchStatusRow, error) {
|
||||
row := q.db.QueryRow(ctx, insertCandidateSearchStatus,
|
||||
arg.UserID,
|
||||
arg.Status,
|
||||
arg.ConfirmedAt,
|
||||
arg.LapsesAt,
|
||||
arg.PolicyVersionID,
|
||||
arg.At,
|
||||
)
|
||||
var i InsertCandidateSearchStatusRow
|
||||
err := row.Scan(&i.UserID, &i.Version)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const listCandidateHiddenOrganizations = `-- name: ListCandidateHiddenOrganizations :many
|
||||
SELECT
|
||||
candidate_hidden_organizations.organization_id,
|
||||
organizations.name AS organization_name,
|
||||
candidate_hidden_organizations.hidden_at
|
||||
FROM candidate_hidden_organizations
|
||||
INNER JOIN organizations
|
||||
ON organizations.id = candidate_hidden_organizations.organization_id
|
||||
WHERE
|
||||
candidate_hidden_organizations.user_id = $1
|
||||
AND (
|
||||
$2::timestamptz IS NULL
|
||||
OR (
|
||||
candidate_hidden_organizations.hidden_at,
|
||||
candidate_hidden_organizations.organization_id
|
||||
) < (
|
||||
$2::timestamptz,
|
||||
$3::uuid
|
||||
)
|
||||
)
|
||||
ORDER BY
|
||||
candidate_hidden_organizations.hidden_at DESC,
|
||||
candidate_hidden_organizations.organization_id DESC
|
||||
LIMIT $4
|
||||
`
|
||||
|
||||
type ListCandidateHiddenOrganizationsParams struct {
|
||||
UserID pgtype.UUID
|
||||
AfterHiddenAt pgtype.Timestamptz
|
||||
AfterOrganizationID pgtype.UUID
|
||||
RowLimit int32
|
||||
}
|
||||
|
||||
type ListCandidateHiddenOrganizationsRow struct {
|
||||
OrganizationID pgtype.UUID
|
||||
OrganizationName string
|
||||
HiddenAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// One page of the candidate's hidden organizations, newest first with the
|
||||
// organization identifier as the tie-breaker. The page continues after the
|
||||
// (hidden_at, organization_id) position of the last record of the previous
|
||||
// page.
|
||||
func (q *Queries) ListCandidateHiddenOrganizations(ctx context.Context, arg ListCandidateHiddenOrganizationsParams) ([]ListCandidateHiddenOrganizationsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listCandidateHiddenOrganizations,
|
||||
arg.UserID,
|
||||
arg.AfterHiddenAt,
|
||||
arg.AfterOrganizationID,
|
||||
arg.RowLimit,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListCandidateHiddenOrganizationsRow
|
||||
for rows.Next() {
|
||||
var i ListCandidateHiddenOrganizationsRow
|
||||
if err := rows.Scan(&i.OrganizationID, &i.OrganizationName, &i.HiddenAt); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const listCandidatePrivacyEvents = `-- name: ListCandidatePrivacyEvents :many
|
||||
SELECT
|
||||
candidate_privacy_events.id,
|
||||
candidate_privacy_events.kind,
|
||||
candidate_privacy_events.occurred_at,
|
||||
candidate_privacy_events.fields,
|
||||
candidate_privacy_events.consent_record_id,
|
||||
candidate_privacy_events.organization_id,
|
||||
organizations.name AS organization_name
|
||||
FROM candidate_privacy_events
|
||||
LEFT JOIN organizations
|
||||
ON organizations.id = candidate_privacy_events.organization_id
|
||||
WHERE
|
||||
candidate_privacy_events.user_id = $1
|
||||
AND (
|
||||
$2::timestamptz IS NULL
|
||||
OR (candidate_privacy_events.occurred_at, candidate_privacy_events.id) < (
|
||||
$2::timestamptz,
|
||||
$3::uuid
|
||||
)
|
||||
)
|
||||
ORDER BY
|
||||
candidate_privacy_events.occurred_at DESC,
|
||||
candidate_privacy_events.id DESC
|
||||
LIMIT $4
|
||||
`
|
||||
|
||||
type ListCandidatePrivacyEventsParams struct {
|
||||
UserID pgtype.UUID
|
||||
AfterOccurredAt pgtype.Timestamptz
|
||||
AfterID pgtype.UUID
|
||||
RowLimit int32
|
||||
}
|
||||
|
||||
type ListCandidatePrivacyEventsRow struct {
|
||||
ID pgtype.UUID
|
||||
Kind string
|
||||
OccurredAt pgtype.Timestamptz
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
OrganizationName pgtype.Text
|
||||
}
|
||||
|
||||
// One page of the candidate's settings history, newest first with the event
|
||||
// identifier as the tie-breaker. The organization name is resolved here, at
|
||||
// read time, and is the current name. The page continues after the
|
||||
// (occurred_at, id) position of the last event of the previous page.
|
||||
func (q *Queries) ListCandidatePrivacyEvents(ctx context.Context, arg ListCandidatePrivacyEventsParams) ([]ListCandidatePrivacyEventsRow, error) {
|
||||
rows, err := q.db.Query(ctx, listCandidatePrivacyEvents,
|
||||
arg.UserID,
|
||||
arg.AfterOccurredAt,
|
||||
arg.AfterID,
|
||||
arg.RowLimit,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []ListCandidatePrivacyEventsRow
|
||||
for rows.Next() {
|
||||
var i ListCandidatePrivacyEventsRow
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Kind,
|
||||
&i.OccurredAt,
|
||||
&i.Fields,
|
||||
&i.ConsentRecordID,
|
||||
&i.OrganizationID,
|
||||
&i.OrganizationName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const lockCurrentC2Record = `-- name: LockCurrentC2Record :one
|
||||
SELECT id
|
||||
FROM consent_records
|
||||
WHERE
|
||||
subject_id = $1
|
||||
AND purpose = 'c2'
|
||||
AND revoked_at IS NULL
|
||||
ORDER BY granted_at DESC, id DESC
|
||||
LIMIT 1
|
||||
FOR SHARE
|
||||
`
|
||||
|
||||
// Takes the candidate's current unrevoked C2 record for a publication and
|
||||
// keeps it locked until the transaction ends. The share lock conflicts with
|
||||
// the revocation stamp (an UPDATE of the row), so a revocation either commits
|
||||
// before this statement, which then returns no row and the publication is
|
||||
// refused, or waits until the publication transaction commits and closes the
|
||||
// card right after. The caller must run it in the transaction that writes the
|
||||
// publication and must re-read the effective state (ReadCandidatePublication)
|
||||
// in that transaction to build its response.
|
||||
func (q *Queries) LockCurrentC2Record(ctx context.Context, subjectID pgtype.UUID) (pgtype.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, lockCurrentC2Record, subjectID)
|
||||
var id pgtype.UUID
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
}
|
||||
|
||||
const readCandidatePublication = `-- name: ReadCandidatePublication :one
|
||||
|
||||
SELECT
|
||||
candidate_publications.user_id,
|
||||
candidate_publications.state,
|
||||
candidate_publications.fields,
|
||||
candidate_publications.consent_record_id,
|
||||
candidate_publications.published_at,
|
||||
candidate_publications.closed_at,
|
||||
candidate_publications.version,
|
||||
candidate_publications.created_at,
|
||||
candidate_publications.updated_at,
|
||||
consent_records.revoked_at AS consent_revoked_at
|
||||
FROM candidate_publications
|
||||
INNER JOIN consent_records
|
||||
ON consent_records.id = candidate_publications.consent_record_id
|
||||
WHERE candidate_publications.user_id = $1
|
||||
`
|
||||
|
||||
type ReadCandidatePublicationRow struct {
|
||||
UserID pgtype.UUID
|
||||
State string
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
PublishedAt pgtype.Timestamptz
|
||||
ClosedAt pgtype.Timestamptz
|
||||
Version int64
|
||||
CreatedAt pgtype.Timestamptz
|
||||
UpdatedAt pgtype.Timestamptz
|
||||
ConsentRevokedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Queries of the candidate visibility settings (TASK-088): the publication of
|
||||
// the card, the search status, the hidden organizations, and the history of
|
||||
// these settings. Every statement is scoped by the candidate's user_id, and
|
||||
// no statement selects another account's row. No statement reads or writes a
|
||||
// profile value, a name, or a contact. A candidate with no row is closed, not
|
||||
// looking, and hides nobody; no statement creates a row except an explicit
|
||||
// act of the candidate.
|
||||
// Reads the publication with the revocation state of the C2 record behind it
|
||||
// in one statement, so the stored setting and the ledger come from one
|
||||
// snapshot. The effective state is computed from them: published only while
|
||||
// consent_revoked_at is NULL. No row means the candidate never published.
|
||||
func (q *Queries) ReadCandidatePublication(ctx context.Context, userID pgtype.UUID) (ReadCandidatePublicationRow, error) {
|
||||
row := q.db.QueryRow(ctx, readCandidatePublication, userID)
|
||||
var i ReadCandidatePublicationRow
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.State,
|
||||
&i.Fields,
|
||||
&i.ConsentRecordID,
|
||||
&i.PublishedAt,
|
||||
&i.ClosedAt,
|
||||
&i.Version,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
&i.ConsentRevokedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const readCandidateSearchStatus = `-- name: ReadCandidateSearchStatus :one
|
||||
SELECT
|
||||
user_id,
|
||||
status,
|
||||
confirmed_at,
|
||||
lapses_at,
|
||||
policy_version_id,
|
||||
version,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM candidate_search_statuses
|
||||
WHERE user_id = $1
|
||||
`
|
||||
|
||||
// No row means the status was never set, which reads as not looking. The
|
||||
// lapse is computed by the caller from lapses_at and its clock and is never
|
||||
// written.
|
||||
func (q *Queries) ReadCandidateSearchStatus(ctx context.Context, userID pgtype.UUID) (CandidateSearchStatus, error) {
|
||||
row := q.db.QueryRow(ctx, readCandidateSearchStatus, userID)
|
||||
var i CandidateSearchStatus
|
||||
err := row.Scan(
|
||||
&i.UserID,
|
||||
&i.Status,
|
||||
&i.ConfirmedAt,
|
||||
&i.LapsesAt,
|
||||
&i.PolicyVersionID,
|
||||
&i.Version,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const readPublicationVisibleToOrganization = `-- name: ReadPublicationVisibleToOrganization :one
|
||||
SELECT
|
||||
effective.user_id,
|
||||
effective.fields,
|
||||
effective.published_at
|
||||
FROM candidate_effective_publications AS effective
|
||||
WHERE
|
||||
effective.user_id = $1
|
||||
AND NOT exists(
|
||||
SELECT 1 FROM candidate_hidden_organizations AS hidden
|
||||
WHERE
|
||||
hidden.user_id = effective.user_id
|
||||
AND hidden.organization_id = $2
|
||||
)
|
||||
`
|
||||
|
||||
type ReadPublicationVisibleToOrganizationParams struct {
|
||||
UserID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
}
|
||||
|
||||
type ReadPublicationVisibleToOrganizationRow struct {
|
||||
UserID pgtype.UUID
|
||||
Fields []string
|
||||
PublishedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// The organization-facing read of a candidate's publication: the effective
|
||||
// view (published and backed by an unrevoked C2) and no hiding of the reading
|
||||
// organization. No row means the organization reads nothing, whichever of
|
||||
// the reasons applies, so it cannot tell a hidden candidate from an
|
||||
// unpublished one. Every organization-facing read of a publication starts
|
||||
// from this shape (TASK-185, TASK-089, TASK-090).
|
||||
func (q *Queries) ReadPublicationVisibleToOrganization(ctx context.Context, arg ReadPublicationVisibleToOrganizationParams) (ReadPublicationVisibleToOrganizationRow, error) {
|
||||
row := q.db.QueryRow(ctx, readPublicationVisibleToOrganization, arg.UserID, arg.OrganizationID)
|
||||
var i ReadPublicationVisibleToOrganizationRow
|
||||
err := row.Scan(&i.UserID, &i.Fields, &i.PublishedAt)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateCandidatePublication = `-- name: UpdateCandidatePublication :one
|
||||
UPDATE candidate_publications
|
||||
SET
|
||||
state = $1,
|
||||
fields = $2,
|
||||
consent_record_id = $3,
|
||||
published_at = $4,
|
||||
closed_at = $5,
|
||||
version = candidate_publications.version + 1,
|
||||
updated_at = greatest(candidate_publications.updated_at, $6)
|
||||
WHERE
|
||||
candidate_publications.user_id = $7
|
||||
AND candidate_publications.version = $8
|
||||
RETURNING user_id, version
|
||||
`
|
||||
|
||||
type UpdateCandidatePublicationParams struct {
|
||||
State string
|
||||
Fields []string
|
||||
ConsentRecordID pgtype.UUID
|
||||
PublishedAt pgtype.Timestamptz
|
||||
ClosedAt pgtype.Timestamptz
|
||||
At pgtype.Timestamptz
|
||||
UserID pgtype.UUID
|
||||
ExpectedVersion int64
|
||||
}
|
||||
|
||||
type UpdateCandidatePublicationRow struct {
|
||||
UserID pgtype.UUID
|
||||
Version int64
|
||||
}
|
||||
|
||||
// Replaces the publication over the version the caller read and advances the
|
||||
// version in the same statement. No row returns for a stale version, which
|
||||
// the caller answers as a version conflict. The update time never moves back,
|
||||
// as in the profile.
|
||||
func (q *Queries) UpdateCandidatePublication(ctx context.Context, arg UpdateCandidatePublicationParams) (UpdateCandidatePublicationRow, error) {
|
||||
row := q.db.QueryRow(ctx, updateCandidatePublication,
|
||||
arg.State,
|
||||
arg.Fields,
|
||||
arg.ConsentRecordID,
|
||||
arg.PublishedAt,
|
||||
arg.ClosedAt,
|
||||
arg.At,
|
||||
arg.UserID,
|
||||
arg.ExpectedVersion,
|
||||
)
|
||||
var i UpdateCandidatePublicationRow
|
||||
err := row.Scan(&i.UserID, &i.Version)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const updateCandidateSearchStatus = `-- name: UpdateCandidateSearchStatus :one
|
||||
UPDATE candidate_search_statuses
|
||||
SET
|
||||
status = $1,
|
||||
confirmed_at = $2,
|
||||
lapses_at = $3,
|
||||
policy_version_id = $4,
|
||||
version = candidate_search_statuses.version + 1,
|
||||
updated_at = greatest(candidate_search_statuses.updated_at, $5)
|
||||
WHERE
|
||||
candidate_search_statuses.user_id = $6
|
||||
AND candidate_search_statuses.version = $7
|
||||
RETURNING user_id, version
|
||||
`
|
||||
|
||||
type UpdateCandidateSearchStatusParams struct {
|
||||
Status string
|
||||
ConfirmedAt pgtype.Timestamptz
|
||||
LapsesAt pgtype.Timestamptz
|
||||
PolicyVersionID pgtype.UUID
|
||||
At pgtype.Timestamptz
|
||||
UserID pgtype.UUID
|
||||
ExpectedVersion int64
|
||||
}
|
||||
|
||||
type UpdateCandidateSearchStatusRow struct {
|
||||
UserID pgtype.UUID
|
||||
Version int64
|
||||
}
|
||||
|
||||
// Replaces the status over the version the caller read. Looking also stores
|
||||
// the new confirmation, lapse time, and policy version; not looking clears
|
||||
// them. It never names the publication or the hidden organizations.
|
||||
func (q *Queries) UpdateCandidateSearchStatus(ctx context.Context, arg UpdateCandidateSearchStatusParams) (UpdateCandidateSearchStatusRow, error) {
|
||||
row := q.db.QueryRow(ctx, updateCandidateSearchStatus,
|
||||
arg.Status,
|
||||
arg.ConfirmedAt,
|
||||
arg.LapsesAt,
|
||||
arg.PolicyVersionID,
|
||||
arg.At,
|
||||
arg.UserID,
|
||||
arg.ExpectedVersion,
|
||||
)
|
||||
var i UpdateCandidateSearchStatusRow
|
||||
err := row.Scan(&i.UserID, &i.Version)
|
||||
return i, err
|
||||
}
|
||||
@@ -88,9 +88,15 @@ type Querier interface {
|
||||
// returned registration version in the same transaction, rolled back when it
|
||||
// matches no row.
|
||||
ConsumeEmailToken(ctx context.Context, arg ConsumeEmailTokenParams) (EmailToken, error)
|
||||
// Counts the hiding records of one candidate for the settings read.
|
||||
CountCandidateHiddenOrganizations(ctx context.Context, userID pgtype.UUID) (int64, error)
|
||||
// Counts the families of a category that have at least one published
|
||||
// version, however many versions each has.
|
||||
CountPublishedAssessmentFamilies(ctx context.Context, category string) (int32, error)
|
||||
// Lifts one hiding. No row returns when the organization was not hidden, so
|
||||
// the caller writes the history event only for a real deletion and answers
|
||||
// 204 either way.
|
||||
DeleteCandidateHiddenOrganization(ctx context.Context, arg DeleteCandidateHiddenOrganizationParams) (pgtype.UUID, error)
|
||||
// Removes the claims that a save replaces. The adapter calls it after the
|
||||
// version advanced and before it inserts the new set, in one transaction.
|
||||
DeleteCandidateProfileClaims(ctx context.Context, userID pgtype.UUID) error
|
||||
@@ -139,6 +145,9 @@ type Querier interface {
|
||||
GetActiveSessionByTokenHash(ctx context.Context, arg GetActiveSessionByTokenHashParams) (Session, error)
|
||||
GetAssessmentFamilyByID(ctx context.Context, id pgtype.UUID) (AssessmentFamily, error)
|
||||
GetAssessmentFamilyVersion(ctx context.Context, arg GetAssessmentFamilyVersionParams) (AssessmentFamily, error)
|
||||
// Reads one hiding of the candidate with the current name of the
|
||||
// organization.
|
||||
GetCandidateHiddenOrganization(ctx context.Context, arg GetCandidateHiddenOrganizationParams) (GetCandidateHiddenOrganizationRow, error)
|
||||
GetConsentText(ctx context.Context, arg GetConsentTextParams) (ConsentText, error)
|
||||
GetContactConsentRecordByInvitation(ctx context.Context, arg GetContactConsentRecordByInvitationParams) (GetContactConsentRecordByInvitationRow, error)
|
||||
GetCurrentAssessmentCategoryOpening(ctx context.Context, category string) (AssessmentCategoryOpening, error)
|
||||
@@ -222,6 +231,18 @@ type Querier interface {
|
||||
// returns no row instead of an error, so a conflict does not abort the
|
||||
// surrounding transaction.
|
||||
InsertAssessmentFamily(ctx context.Context, arg InsertAssessmentFamilyParams) (AssessmentFamily, error)
|
||||
// Hides one organization. No row returns when the pair already exists, and
|
||||
// the caller reads the existing record with its original time. The foreign key
|
||||
// refuses an unknown organization (SQLSTATE 23503); the caller answers it
|
||||
// exactly like an organization the candidate cannot see. The trigger refuses
|
||||
// the 1001st record (candidate_hidden_organizations_limit). The trigger runs
|
||||
// before the conflict check, so the caller reads the existing record first
|
||||
// and a repeat at the limit is never refused.
|
||||
InsertCandidateHiddenOrganization(ctx context.Context, arg InsertCandidateHiddenOrganizationParams) (CandidateHiddenOrganization, error)
|
||||
// Appends one event to the settings history. The row holds identifiers, card
|
||||
// field codes, and times, never a name; the caller
|
||||
// writes it in the transaction of the change it records.
|
||||
InsertCandidatePrivacyEvent(ctx context.Context, arg InsertCandidatePrivacyEventParams) error
|
||||
// Queries of the manual candidate profile (TASK-066). The profile is personal
|
||||
// data of the account that owns it: every statement is scoped by user_id, and
|
||||
// no statement selects another account's row. None of them names a file, the
|
||||
@@ -235,6 +256,13 @@ type Querier interface {
|
||||
// statement never takes a trust level from the caller, because every claim
|
||||
// has level 0.
|
||||
InsertCandidateProfileClaim(ctx context.Context, arg InsertCandidateProfileClaimParams) error
|
||||
// Stores the first publication at version 1. No row returns when the account
|
||||
// already has a row, so a first publication that lost a race with another
|
||||
// one is answered as a version conflict. The foreign key refuses a record
|
||||
// that is not a C2 record of this account.
|
||||
InsertCandidatePublication(ctx context.Context, arg InsertCandidatePublicationParams) (InsertCandidatePublicationRow, error)
|
||||
// Stores the first status at version 1; no row returns when one exists.
|
||||
InsertCandidateSearchStatus(ctx context.Context, arg InsertCandidateSearchStatusParams) (InsertCandidateSearchStatusRow, error)
|
||||
// Records a grant of C1, C2, C3, or C5. An unrevoked record of the same
|
||||
// subject, purpose, and text version already exists when no row returns;
|
||||
// the insert then changes nothing and does not abort the transaction.
|
||||
@@ -297,6 +325,16 @@ type Querier interface {
|
||||
// given position; an empty key and version 0 start at the beginning. The
|
||||
// (family_key, version) unique index serves the scan.
|
||||
ListAssessmentFamiliesByCategory(ctx context.Context, arg ListAssessmentFamiliesByCategoryParams) ([]AssessmentFamily, error)
|
||||
// One page of the candidate's hidden organizations, newest first with the
|
||||
// organization identifier as the tie-breaker. The page continues after the
|
||||
// (hidden_at, organization_id) position of the last record of the previous
|
||||
// page.
|
||||
ListCandidateHiddenOrganizations(ctx context.Context, arg ListCandidateHiddenOrganizationsParams) ([]ListCandidateHiddenOrganizationsRow, error)
|
||||
// One page of the candidate's settings history, newest first with the event
|
||||
// identifier as the tie-breaker. The organization name is resolved here, at
|
||||
// read time, and is the current name. The page continues after the
|
||||
// (occurred_at, id) position of the last event of the previous page.
|
||||
ListCandidatePrivacyEvents(ctx context.Context, arg ListCandidatePrivacyEventsParams) ([]ListCandidatePrivacyEventsRow, error)
|
||||
// One page of the subject's ledger, newest grant first, optionally limited
|
||||
// to one state. Every record query is scoped by the subject, so a caller
|
||||
// never reads or revokes another subject's consent. The state is computed,
|
||||
@@ -329,6 +367,15 @@ type Querier interface {
|
||||
// canceled, or reclaimed after the lease expired. While the lock is held,
|
||||
// other workers skip the row, so the handler never runs twice at once.
|
||||
LockClaimedScheduledJob(ctx context.Context, arg LockClaimedScheduledJobParams) (int64, error)
|
||||
// Takes the candidate's current unrevoked C2 record for a publication and
|
||||
// keeps it locked until the transaction ends. The share lock conflicts with
|
||||
// the revocation stamp (an UPDATE of the row), so a revocation either commits
|
||||
// before this statement, which then returns no row and the publication is
|
||||
// refused, or waits until the publication transaction commits and closes the
|
||||
// card right after. The caller must run it in the transaction that writes the
|
||||
// publication and must re-read the effective state (ReadCandidatePublication)
|
||||
// in that transaction to build its response.
|
||||
LockCurrentC2Record(ctx context.Context, subjectID pgtype.UUID) (pgtype.UUID, error)
|
||||
// Locks the listed window rows until the transaction ends, in
|
||||
// (period_kind, period_start) order, the same order for every caller, and
|
||||
// returns their usage. Under READ COMMITTED a waiting caller reads the usage
|
||||
@@ -387,6 +434,29 @@ type Querier interface {
|
||||
// 0). Claims come in a stable order: single fields by kind, list items by
|
||||
// position. Never replace this with two statements.
|
||||
ReadCandidateProfile(ctx context.Context, userID pgtype.UUID) ([]ReadCandidateProfileRow, error)
|
||||
// Queries of the candidate visibility settings (TASK-088): the publication of
|
||||
// the card, the search status, the hidden organizations, and the history of
|
||||
// these settings. Every statement is scoped by the candidate's user_id, and
|
||||
// no statement selects another account's row. No statement reads or writes a
|
||||
// profile value, a name, or a contact. A candidate with no row is closed, not
|
||||
// looking, and hides nobody; no statement creates a row except an explicit
|
||||
// act of the candidate.
|
||||
// Reads the publication with the revocation state of the C2 record behind it
|
||||
// in one statement, so the stored setting and the ledger come from one
|
||||
// snapshot. The effective state is computed from them: published only while
|
||||
// consent_revoked_at is NULL. No row means the candidate never published.
|
||||
ReadCandidatePublication(ctx context.Context, userID pgtype.UUID) (ReadCandidatePublicationRow, error)
|
||||
// No row means the status was never set, which reads as not looking. The
|
||||
// lapse is computed by the caller from lapses_at and its clock and is never
|
||||
// written.
|
||||
ReadCandidateSearchStatus(ctx context.Context, userID pgtype.UUID) (CandidateSearchStatus, error)
|
||||
// The organization-facing read of a candidate's publication: the effective
|
||||
// view (published and backed by an unrevoked C2) and no hiding of the reading
|
||||
// organization. No row means the organization reads nothing, whichever of
|
||||
// the reasons applies, so it cannot tell a hidden candidate from an
|
||||
// unpublished one. Every organization-facing read of a publication starts
|
||||
// from this shape (TASK-185, TASK-089, TASK-090).
|
||||
ReadPublicationVisibleToOrganization(ctx context.Context, arg ReadPublicationVisibleToOrganizationParams) (ReadPublicationVisibleToOrganizationRow, error)
|
||||
// Advances a delivery past one attempt and appends the attempt in one
|
||||
// statement, so both happen or neither does, inside or outside a
|
||||
// transaction. The update applies only while the stored version still
|
||||
@@ -480,6 +550,15 @@ type Querier interface {
|
||||
// revoked, expired, or idle session is not revived; the update re-checks
|
||||
// those conditions against a concurrent change.
|
||||
TouchSession(ctx context.Context, arg TouchSessionParams) (TouchSessionRow, error)
|
||||
// Replaces the publication over the version the caller read and advances the
|
||||
// version in the same statement. No row returns for a stale version, which
|
||||
// the caller answers as a version conflict. The update time never moves back,
|
||||
// as in the profile.
|
||||
UpdateCandidatePublication(ctx context.Context, arg UpdateCandidatePublicationParams) (UpdateCandidatePublicationRow, error)
|
||||
// Replaces the status over the version the caller read. Looking also stores
|
||||
// the new confirmation, lapse time, and policy version; not looking clears
|
||||
// them. It never names the publication or the hidden organizations.
|
||||
UpdateCandidateSearchStatus(ctx context.Context, arg UpdateCandidateSearchStatusParams) (UpdateCandidateSearchStatusRow, error)
|
||||
// Stores a change of the delivery state that is not an attempt: a quota wait,
|
||||
// a cancellation, or a new provider account before the first attempt. It
|
||||
// applies only while the stored version still equals expected_version and
|
||||
|
||||
Reference in new issue
Block a user