feat(platform): add the notification inbox and deterministic match search

This commit is contained in:
shira committed 2026-10-09 13:14:46 +03:00
1 parent 5edff21d2d
commit 0b11021b16
169 files changed
+17083 -443

No files matched your search

+39 -3
View File
@@ -69,13 +69,19 @@ WHERE recipient_user_id = sqlc.arg(recipient_user_id)
ORDER BY occurred_at DESC, event_id DESC
LIMIT sqlc.arg(page_limit);
-- Persist the first read time under exact recipient and organization scope.
-- Repeated calls preserve the original read timestamp.
-- Persist the first read time for the recipient, optionally under one exact
-- organization context. A missing organization is the candidate cabinet,
-- which spans the organizations that sent to it; the employer cabinet always
-- names its organization. Repeated calls preserve the original read
-- timestamp.
-- name: MarkNotificationInboxEventRead :one
UPDATE notification_inbox_events
SET read_at = COALESCE(read_at, sqlc.arg(read_at)::timestamptz)
WHERE recipient_user_id = sqlc.arg(recipient_user_id)
AND organization_id = sqlc.arg(organization_id)
AND (
sqlc.narg(organization_id)::uuid IS NULL
OR organization_id = sqlc.narg(organization_id)::uuid
)
AND event_id = sqlc.arg(event_id)
RETURNING
recipient_user_id,
@@ -87,3 +93,33 @@ RETURNING
source_id,
occurred_at,
read_at;
-- Resolve the sender organization of a synthetic notice under the recipient's
-- current standing, so the notice never outlives that standing. A candidate
-- sees the name only while the organization is not hidden from them; an
-- employer sees it only while they are an active member. No row means the
-- content is no longer visible to this recipient.
-- name: GetNotificationOrganizationNameForRecipient :one
SELECT organizations.name
FROM organizations
INNER JOIN users ON users.id = sqlc.arg(recipient_user_id)
WHERE organizations.id = sqlc.arg(organization_id)
AND (
(
users.scenario = 'candidate'
AND NOT EXISTS (
SELECT 1 FROM candidate_hidden_organizations
WHERE candidate_hidden_organizations.user_id = users.id
AND candidate_hidden_organizations.organization_id = organizations.id
)
)
OR (
users.scenario = 'employer'
AND EXISTS (
SELECT 1 FROM memberships
WHERE memberships.user_id = users.id
AND memberships.organization_id = organizations.id
AND memberships.state = 'active'
)
)
);