feat(invitations): check contact grants on every read, cap pending invitations, and expire them at the deadline
This commit is contained in:
1 parent
676b3c6e24
commit
12a7213d4a
67 files changed
+4255
-149
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: invitation_pending.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const countPendingNeedInvitations = `-- name: CountPendingNeedInvitations :one
|
||||
SELECT count(*)::bigint AS pending
|
||||
FROM invitations
|
||||
WHERE
|
||||
organization_id = $1
|
||||
AND need_id = $2
|
||||
AND state IN ('delivered', 'viewed', 'counter')
|
||||
`
|
||||
|
||||
type CountPendingNeedInvitationsParams struct {
|
||||
OrganizationID pgtype.UUID
|
||||
NeedID pgtype.UUID
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (q *Queries) CountPendingNeedInvitations(ctx context.Context, arg CountPendingNeedInvitationsParams) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countPendingNeedInvitations, arg.OrganizationID, arg.NeedID)
|
||||
var pending int64
|
||||
err := row.Scan(&pending)
|
||||
return pending, err
|
||||
}
|
||||
Reference in new issue
Block a user