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
@@ -57,6 +57,21 @@ func (q *Queries) GetMembership(ctx context.Context, arg GetMembershipParams) (M
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getOrganizationCreationResult = `-- name: GetOrganizationCreationResult :one
|
||||
SELECT snapshot
|
||||
FROM organization_creation_results
|
||||
WHERE scope_hash = $1
|
||||
`
|
||||
|
||||
// Reads only the historical result. It intentionally does not join the live
|
||||
// organization or membership, whose profile and state may have since changed.
|
||||
func (q *Queries) GetOrganizationCreationResult(ctx context.Context, scopeHash []byte) ([]byte, error) {
|
||||
row := q.db.QueryRow(ctx, getOrganizationCreationResult, scopeHash)
|
||||
var snapshot []byte
|
||||
err := row.Scan(&snapshot)
|
||||
return snapshot, err
|
||||
}
|
||||
|
||||
const getOrganizationForMember = `-- name: GetOrganizationForMember :one
|
||||
SELECT
|
||||
organization.id,
|
||||
@@ -390,6 +405,27 @@ func (q *Queries) ListOrganizationsForUser(ctx context.Context, arg ListOrganiza
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const saveOrganizationCreationResult = `-- name: SaveOrganizationCreationResult :exec
|
||||
INSERT INTO organization_creation_results (scope_hash, snapshot)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (scope_hash) DO UPDATE
|
||||
SET snapshot = excluded.snapshot
|
||||
`
|
||||
|
||||
type SaveOrganizationCreationResultParams struct {
|
||||
ScopeHash []byte
|
||||
Snapshot []byte
|
||||
}
|
||||
|
||||
// Stores the immutable domain snapshot of a successful create command. The
|
||||
// generic idempotency row and this result are committed with the organization
|
||||
// and owner membership. A reused expired scope replaces the snapshot in the
|
||||
// same transaction as the new organization.
|
||||
func (q *Queries) SaveOrganizationCreationResult(ctx context.Context, arg SaveOrganizationCreationResultParams) error {
|
||||
_, err := q.db.Exec(ctx, saveOrganizationCreationResult, arg.ScopeHash, arg.Snapshot)
|
||||
return err
|
||||
}
|
||||
|
||||
const updateOrganizationProfile = `-- name: UpdateOrganizationProfile :one
|
||||
WITH target AS (
|
||||
SELECT id FROM organizations
|
||||
|
||||
Reference in new issue
Block a user