feat(invitations): send invitations into the candidate inbox atomically
This commit is contained in:
1 parent
fc35e27af5
commit
1a067221f7
46 files changed
+3276
-113
No files matched your search
@@ -518,7 +518,7 @@ export const useUpdateOrganizationInvitation = <TError = ErrorType<Problem>,
|
||||
*
|
||||
* Sends the current terms version of a `draft`. Sending is internal and never visible as a state: in one transaction the server records the delivery, creates the candidate's inbox entry, starts the deadline `response_deadline_at = delivered_at + response_period_days`, spends one invitation of the weekly organization quota, and writes the outbox event for the notification, then answers 200 with the state `delivered`. A successful answer therefore means the candidate can already read the invitation; an email is a separate notification that never blocks or delays it, and its retries never move the deadline. No contact of the candidate is disclosed by sending.
|
||||
*
|
||||
* The server checks again that the candidate is still visible to the organization: a revoked publication C2 or a profile hidden from the organization answers 409 state_conflict without telling which. It also enforces the limits of the product policy: at most 20 invitations waiting for an answer per need (`delivered`, `viewed`, `counter`) and the 30-day pause for the pair of the organization and the candidate after a decline or a no deal, regardless of the member or the need, both with 409 state_conflict; and the rolling weekly quota of the organization, with 429 and Retry-After. Enforcement of the pending limit and the organization quota is planned.
|
||||
* The server checks again that the candidate is still visible to the organization: a revoked publication C2 or a profile hidden from the organization answers 409 state_conflict without telling which. It also enforces the limits of the product policy: at most 20 invitations waiting for an answer per need (`delivered`, `viewed`, `counter`) and the 30-day pause for the pair of the organization and the candidate after a decline or a no deal, regardless of the member or the need, both with 409 state_conflict; and the rolling weekly quota of the organization, with 429 and Retry-After. The organization quota is enforced; the pending limit and the pause are planned and are not checked yet.
|
||||
*
|
||||
* Repeats return the same result: a retry with the same Idempotency-Key replays the stored response, and a send of an invitation that was already sent answers 200 with the invitation in its current state even with a new key or an older `expected_version`; the quota is spent once. A stale `expected_version` on a draft answers 412 version_conflict, so the organization never sends terms it did not read.
|
||||
*
|
||||
|
||||
@@ -17,7 +17,7 @@ export const notificationContentOneLinkPathRegExp = new RegExp('^/[A-Za-z0-9/_-]
|
||||
|
||||
export const Notification = zod.object({
|
||||
"id": zod.uuid().describe('Identifier of the item. It equals the identifier of the event that produced it, so a repeated delivery of the same event is the same item.'),
|
||||
"kind": zod.enum(['invitation_delivered', 'synthetic']).describe('Which event put the notification into the inbox. The inbox stores a reference to the event, never its text.\n\n- invitation_delivered: an invitation reached the candidate\'s inbox. This is the in-platform delivery state of the invitation: it does not depend on any email, and a failed or missing email never blocks it. The invitation operations are planned; no invitation produces a notification yet.\n- synthetic: a synthetic notice that exercises the inbox path (the event, the read-time visibility check, the list, and the read state). It has no product meaning, needs no action, and is never produced by a user action.\n\nAdding a value is a contract change; a client shows an unknown kind with the generic text of an item without content.'),
|
||||
"kind": zod.enum(['invitation_delivered', 'synthetic']).describe('Which event put the notification into the inbox. The inbox stores a reference to the event, never its text.\n\n- invitation_delivered: an invitation reached the candidate\'s inbox. It does not depend on any email, and a failed or missing email never blocks it. The send of an invitation produces it through the outbox, so the notice appears shortly after the commit of the send, while the invitation itself is in ListMyInvitations from that commit.\n- synthetic: a synthetic notice that exercises the inbox path (the event, the read-time visibility check, the list, and the read state). It has no product meaning, needs no action, and is never produced by a user action.\n\nAdding a value is a contract change; a client shows an unknown kind with the generic text of an item without content.'),
|
||||
"organization_id": zod.uuid().describe('The organization context of the item: the organization that sent it to a candidate, or the organization whose cabinet holds it for an employer. The identifier is not a right to read the organization.'),
|
||||
"delivered_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'),
|
||||
"read_at": zod.union([zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'),zod.null()]).describe('When the recipient first marked the item read, or null while it is unread. A repeated mark keeps the first time.'),
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
import * as zod from 'zod';
|
||||
|
||||
export const NotificationKind = zod.enum(['invitation_delivered', 'synthetic']).describe('Which event put the notification into the inbox. The inbox stores a reference to the event, never its text.\n\n- invitation_delivered: an invitation reached the candidate\'s inbox. This is the in-platform delivery state of the invitation: it does not depend on any email, and a failed or missing email never blocks it. The invitation operations are planned; no invitation produces a notification yet.\n- synthetic: a synthetic notice that exercises the inbox path (the event, the read-time visibility check, the list, and the read state). It has no product meaning, needs no action, and is never produced by a user action.\n\nAdding a value is a contract change; a client shows an unknown kind with the generic text of an item without content.')
|
||||
export const NotificationKind = zod.enum(['invitation_delivered', 'synthetic']).describe('Which event put the notification into the inbox. The inbox stores a reference to the event, never its text.\n\n- invitation_delivered: an invitation reached the candidate\'s inbox. It does not depend on any email, and a failed or missing email never blocks it. The send of an invitation produces it through the outbox, so the notice appears shortly after the commit of the send, while the invitation itself is in ListMyInvitations from that commit.\n- synthetic: a synthetic notice that exercises the inbox path (the event, the read-time visibility check, the list, and the read state). It has no product meaning, needs no action, and is never produced by a user action.\n\nAdding a value is a contract change; a client shows an unknown kind with the generic text of an item without content.')
|
||||
|
||||
export type NotificationKind = zod.input<typeof NotificationKind>;
|
||||
export type NotificationKindOutput = zod.output<typeof NotificationKind>;
|
||||
@@ -24,7 +24,7 @@ export const notificationListPageNextCursorRegExp = new RegExp('^[A-Za-z0-9_-]+$
|
||||
export const NotificationList = zod.object({
|
||||
"items": zod.array(zod.object({
|
||||
"id": zod.uuid().describe('Identifier of the item. It equals the identifier of the event that produced it, so a repeated delivery of the same event is the same item.'),
|
||||
"kind": zod.enum(['invitation_delivered', 'synthetic']).describe('Which event put the notification into the inbox. The inbox stores a reference to the event, never its text.\n\n- invitation_delivered: an invitation reached the candidate\'s inbox. This is the in-platform delivery state of the invitation: it does not depend on any email, and a failed or missing email never blocks it. The invitation operations are planned; no invitation produces a notification yet.\n- synthetic: a synthetic notice that exercises the inbox path (the event, the read-time visibility check, the list, and the read state). It has no product meaning, needs no action, and is never produced by a user action.\n\nAdding a value is a contract change; a client shows an unknown kind with the generic text of an item without content.'),
|
||||
"kind": zod.enum(['invitation_delivered', 'synthetic']).describe('Which event put the notification into the inbox. The inbox stores a reference to the event, never its text.\n\n- invitation_delivered: an invitation reached the candidate\'s inbox. It does not depend on any email, and a failed or missing email never blocks it. The send of an invitation produces it through the outbox, so the notice appears shortly after the commit of the send, while the invitation itself is in ListMyInvitations from that commit.\n- synthetic: a synthetic notice that exercises the inbox path (the event, the read-time visibility check, the list, and the read state). It has no product meaning, needs no action, and is never produced by a user action.\n\nAdding a value is a contract change; a client shows an unknown kind with the generic text of an item without content.'),
|
||||
"organization_id": zod.uuid().describe('The organization context of the item: the organization that sent it to a candidate, or the organization whose cabinet holds it for an employer. The identifier is not a right to read the organization.'),
|
||||
"delivered_at": zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'),
|
||||
"read_at": zod.union([zod.iso.datetime({"offset":true}).describe('UTC instant in RFC 3339 format with the Z suffix, for example 2026-10-05T09:30:00Z. Servers always emit UTC. Every date-time field in this contract uses this schema.'),zod.null()]).describe('When the recipient first marked the item read, or null while it is unread. A repeated mark keeps the first time.'),
|
||||
|
||||
Reference in new issue
Block a user