feat(invitations): accept invitations with C4 consent and contact grants; share the E0 quota across holdings
This commit is contained in:
1 parent
a5990d3fc6
commit
676b3c6e24
59 files changed
+4926
-194
No files matched your search
@@ -0,0 +1,111 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: contact_grants.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getContactGrantByInvitation = `-- name: GetContactGrantByInvitation :one
|
||||
SELECT
|
||||
id,
|
||||
organization_id,
|
||||
candidate_id,
|
||||
source_invitation_id,
|
||||
consent_record_id,
|
||||
terms_version,
|
||||
fields,
|
||||
consent_text_version,
|
||||
granted_at,
|
||||
revoked_at,
|
||||
revocation_reason
|
||||
FROM contact_grants
|
||||
WHERE
|
||||
organization_id = $1
|
||||
AND source_invitation_id = $2
|
||||
`
|
||||
|
||||
type GetContactGrantByInvitationParams struct {
|
||||
OrganizationID pgtype.UUID
|
||||
InvitationID pgtype.UUID
|
||||
}
|
||||
|
||||
// Read the grant of one invitation of one organization. An invitation of
|
||||
// another organization finds nothing.
|
||||
func (q *Queries) GetContactGrantByInvitation(ctx context.Context, arg GetContactGrantByInvitationParams) (ContactGrant, error) {
|
||||
row := q.db.QueryRow(ctx, getContactGrantByInvitation, arg.OrganizationID, arg.InvitationID)
|
||||
var i ContactGrant
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.OrganizationID,
|
||||
&i.CandidateID,
|
||||
&i.SourceInvitationID,
|
||||
&i.ConsentRecordID,
|
||||
&i.TermsVersion,
|
||||
&i.Fields,
|
||||
&i.ConsentTextVersion,
|
||||
&i.GrantedAt,
|
||||
&i.RevokedAt,
|
||||
&i.RevocationReason,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const insertContactGrant = `-- name: InsertContactGrant :exec
|
||||
INSERT INTO contact_grants (
|
||||
id,
|
||||
organization_id,
|
||||
candidate_id,
|
||||
source_invitation_id,
|
||||
consent_record_id,
|
||||
terms_version,
|
||||
fields,
|
||||
consent_text_version,
|
||||
granted_at
|
||||
) VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5,
|
||||
$6,
|
||||
$7::text [],
|
||||
$8,
|
||||
$9
|
||||
)
|
||||
`
|
||||
|
||||
type InsertContactGrantParams struct {
|
||||
ID pgtype.UUID
|
||||
OrganizationID pgtype.UUID
|
||||
CandidateID pgtype.UUID
|
||||
SourceInvitationID pgtype.UUID
|
||||
ConsentRecordID pgtype.UUID
|
||||
TermsVersion int64
|
||||
Fields []string
|
||||
ConsentTextVersion string
|
||||
GrantedAt pgtype.Timestamptz
|
||||
}
|
||||
|
||||
// Store the contact grant of an acceptance. The row is inserted in the same
|
||||
// transaction as its C4 consent record and the accepted state; the database
|
||||
// checks that the record, the invitation, and the candidate agree.
|
||||
func (q *Queries) InsertContactGrant(ctx context.Context, arg InsertContactGrantParams) error {
|
||||
_, err := q.db.Exec(ctx, insertContactGrant,
|
||||
arg.ID,
|
||||
arg.OrganizationID,
|
||||
arg.CandidateID,
|
||||
arg.SourceInvitationID,
|
||||
arg.ConsentRecordID,
|
||||
arg.TermsVersion,
|
||||
arg.Fields,
|
||||
arg.ConsentTextVersion,
|
||||
arg.GrantedAt,
|
||||
)
|
||||
return err
|
||||
}
|
||||
Reference in new issue
Block a user