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

@@ -51,6 +51,49 @@ func (q *Queries) GetNotificationInboxEvent(ctx context.Context, arg GetNotifica
return i, err
}
const getNotificationOrganizationNameForRecipient = `-- name: GetNotificationOrganizationNameForRecipient :one
SELECT organizations.name
FROM organizations
INNER JOIN users ON users.id = $1
WHERE organizations.id = $2
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'
)
)
)
`
type GetNotificationOrganizationNameForRecipientParams struct {
RecipientUserID pgtype.UUID
OrganizationID pgtype.UUID
}
// 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.
func (q *Queries) GetNotificationOrganizationNameForRecipient(ctx context.Context, arg GetNotificationOrganizationNameForRecipientParams) (string, error) {
row := q.db.QueryRow(ctx, getNotificationOrganizationNameForRecipient, arg.RecipientUserID, arg.OrganizationID)
var name string
err := row.Scan(&name)
return name, err
}
const insertNotificationInboxEvent = `-- name: InsertNotificationInboxEvent :execrows
INSERT INTO notification_inbox_events (
recipient_user_id,
@@ -183,7 +226,10 @@ const markNotificationInboxEventRead = `-- name: MarkNotificationInboxEventRead
UPDATE notification_inbox_events
SET read_at = COALESCE(read_at, $1::timestamptz)
WHERE recipient_user_id = $2
AND organization_id = $3
AND (
$3::uuid IS NULL
OR organization_id = $3::uuid
)
AND event_id = $4
RETURNING
recipient_user_id,
@@ -204,8 +250,11 @@ type MarkNotificationInboxEventReadParams struct {
EventID pgtype.UUID
}
// 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.
func (q *Queries) MarkNotificationInboxEventRead(ctx context.Context, arg MarkNotificationInboxEventReadParams) (NotificationInboxEvent, error) {
row := q.db.QueryRow(ctx, markNotificationInboxEventRead,
arg.ReadAt,