mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 15:31:13 -05:00
Approve tool use
The user has approved the tool use.
This commit is contained in:
@@ -177,14 +177,42 @@ export async function approvePhotoSubmission(
|
||||
* @param itemIds - Array of item IDs to approve
|
||||
* @returns Action result
|
||||
*/
|
||||
/**
|
||||
* Feature flag to enable atomic transaction RPC approval flow.
|
||||
* Set to true to use the new process-selective-approval-v2 edge function
|
||||
* that wraps the entire approval in a single PostgreSQL transaction.
|
||||
*
|
||||
* Benefits of v2:
|
||||
* - True atomic transactions (all-or-nothing)
|
||||
* - Automatic rollback on ANY error
|
||||
* - Network-resilient (edge function crash = auto rollback)
|
||||
* - Eliminates orphaned entities
|
||||
*
|
||||
* To enable: localStorage.setItem('use_rpc_approval', 'true')
|
||||
* To disable: localStorage.setItem('use_rpc_approval', 'false')
|
||||
*/
|
||||
const USE_RPC_APPROVAL = typeof window !== 'undefined' &&
|
||||
localStorage.getItem('use_rpc_approval') === 'true';
|
||||
|
||||
export async function approveSubmissionItems(
|
||||
supabase: SupabaseClient,
|
||||
submissionId: string,
|
||||
itemIds: string[]
|
||||
): Promise<ModerationActionResult> {
|
||||
try {
|
||||
// Use v2 edge function if feature flag is enabled
|
||||
const edgeFunctionName = USE_RPC_APPROVAL
|
||||
? 'process-selective-approval-v2'
|
||||
: 'process-selective-approval';
|
||||
|
||||
console.log(`[Approval] Using edge function: ${edgeFunctionName}`, {
|
||||
submissionId,
|
||||
itemCount: itemIds.length,
|
||||
useRpcApproval: USE_RPC_APPROVAL
|
||||
});
|
||||
|
||||
const { data: approvalData, error: approvalError, requestId } = await invokeWithTracking(
|
||||
'process-selective-approval',
|
||||
edgeFunctionName,
|
||||
{
|
||||
itemIds,
|
||||
submissionId,
|
||||
|
||||
Reference in New Issue
Block a user