feat(accounts): add consent settings and organization management
This commit is contained in:
1 parent
24638d46d2
commit
391af7a1ef
83 files changed
+10198
-613
No files matched your search
@@ -421,6 +421,38 @@ func (q *Queries) ListCandidatePrivacyEvents(ctx context.Context, arg ListCandid
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const lockCandidatePublicationForConsentRevocation = `-- name: LockCandidatePublicationForConsentRevocation :one
|
||||
SELECT greatest(candidate_publications.published_at, consent_records.revoked_at)::timestamptz AS closed_at
|
||||
FROM candidate_publications
|
||||
INNER JOIN consent_records
|
||||
ON consent_records.id = candidate_publications.consent_record_id
|
||||
WHERE
|
||||
candidate_publications.user_id = $1
|
||||
AND candidate_publications.state = 'published'
|
||||
AND consent_records.id = ANY($2::uuid [])
|
||||
AND consent_records.subject_id = candidate_publications.user_id
|
||||
AND consent_records.purpose = 'c2'
|
||||
AND consent_records.revoked_at IS NOT NULL
|
||||
FOR UPDATE OF candidate_publications
|
||||
`
|
||||
|
||||
type LockCandidatePublicationForConsentRevocationParams struct {
|
||||
UserID pgtype.UUID
|
||||
ConsentRecordIds []pgtype.UUID
|
||||
}
|
||||
|
||||
// Locks the candidate's published row only when it refers to a C2 record
|
||||
// revoked by this transaction. The setting remains linked to that immutable
|
||||
// record; ReadCandidatePublication computes the effective closed state and
|
||||
// keeps the consent-revoked reason after later grants. The returned time is
|
||||
// the effective close time used by the privacy history event.
|
||||
func (q *Queries) LockCandidatePublicationForConsentRevocation(ctx context.Context, arg LockCandidatePublicationForConsentRevocationParams) (pgtype.Timestamptz, error) {
|
||||
row := q.db.QueryRow(ctx, lockCandidatePublicationForConsentRevocation, arg.UserID, arg.ConsentRecordIds)
|
||||
var closed_at pgtype.Timestamptz
|
||||
err := row.Scan(&closed_at)
|
||||
return closed_at, err
|
||||
}
|
||||
|
||||
const lockCurrentC2Record = `-- name: LockCurrentC2Record :one
|
||||
SELECT id
|
||||
FROM consent_records
|
||||
|
||||
Reference in new issue
Block a user