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

@@ -0,0 +1,39 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: invitation_cooldowns.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const latestInvitationDecline = `-- name: LatestInvitationDecline :one
SELECT responded_at AS declined_at
FROM invitations
WHERE
organization_id = $1
AND candidate_id = $2
AND state = 'declined'
ORDER BY responded_at DESC
LIMIT 1
`
type LatestInvitationDeclineParams struct {
OrganizationID pgtype.UUID
CandidateID pgtype.UUID
}
// The time of the latest decline of one candidate by one organization, across
// every need and every member of the organization. The pause that follows it is
// applied by the send, from the policy in force. A candidate without a decline
// finds no row.
func (q *Queries) LatestInvitationDecline(ctx context.Context, arg LatestInvitationDeclineParams) (pgtype.Timestamptz, error) {
row := q.db.QueryRow(ctx, latestInvitationDecline, arg.OrganizationID, arg.CandidateID)
var declined_at pgtype.Timestamptz
err := row.Scan(&declined_at)
return declined_at, err
}