feat(invitations): check contact grants on every read, cap pending invitations, and expire them at the deadline

This commit is contained in:
shira committed 2026-10-09 19:06:50 +03:00
1 parent 676b3c6e24
commit 12a7213d4a
67 files changed
+4255 -149

No files matched your search

+25 -6
View File
@@ -459,6 +459,26 @@ const (
InvitationContactAccessClosed InvitationContactAccess = "closed"
)
// InvitationContactAccessView is the contact access of the organization through
// one invitation. Fields are the kinds that the contact read returns while the
// status is available; the other states list none. It never holds a contact
// value, and it names no reason, because the organization is not told one.
type InvitationContactAccessView struct {
Status InvitationContactAccess `json:"status"`
Fields []ContactField `json:"fields"`
}
// NewInvitationContactAccessView builds the view of a status. Fields are kept
// only for an available access, and the list is never nil, so it serializes as
// an empty array.
func NewInvitationContactAccessView(status InvitationContactAccess, fields []ContactField) InvitationContactAccessView {
view := InvitationContactAccessView{Status: status, Fields: []ContactField{}}
if status == InvitationContactAccessAvailable {
view.Fields = append(view.Fields, fields...)
}
return view
}
// InvitationSnapshot is the serializable part of an invitation that an
// organization may read. It has no candidate identifier, so it cannot reveal
// who the invitation is for.
@@ -500,15 +520,14 @@ func (invitation Invitation) Snapshot() InvitationSnapshot {
// OrganizationInvitationView is an invitation as its organization reads it:
// the snapshot, the organization-scoped alias of the candidate, the coarse
// salary indicator, and the state of the contact access without any contact
// value. It also serves as the stored original response of an idempotent
// create.
// salary indicator, and the contact access without any contact value. It also
// serves as the stored original response of an idempotent create or send.
type OrganizationInvitationView struct {
InvitationSnapshot
CandidateHandle string `json:"candidate_handle"`
SalaryFit InvitationSalaryFit `json:"salary_fit"`
ContactAccess InvitationContactAccess `json:"contact_access"`
CandidateHandle string `json:"candidate_handle"`
SalaryFit InvitationSalaryFit `json:"salary_fit"`
ContactAccess InvitationContactAccessView `json:"contact_access"`
}
func (invitation Invitation) String() string { return redactedInvitation }