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

+11
View File
@@ -0,0 +1,11 @@
-- Counts the invitations of one organization need that wait for an answer:
-- delivered, viewed, or the planned counter offer. The send counts them under
-- the organization lock, which every send takes first, so no other send can
-- add a waiting invitation between the count and its own delivery.
-- name: CountPendingNeedInvitations :one
SELECT count(*)::bigint AS pending
FROM invitations
WHERE
organization_id = sqlc.arg(organization_id)
AND need_id = sqlc.arg(need_id)
AND state IN ('delivered', 'viewed', 'counter');