0ac4beaaa8
- Add requireAuth() to admin-permissions.ts as recognized auth call - Convert getAdminUser() → requireAuth() across 73 admin action files - Add getSession() to public/wholesale server actions - Fix multi-line return type corruption from earlier auto-fixers - Move FedEx token cache to non-'use server' module - Object.freeze module-level constants: PRICE_KEYS, EMPTY_MOBILE_DASHBOARD, EMPTY_PAY_PERIOD, LOCALE_CART_SUBJECT, WELCOME_EMAILS - Update Stripe API version 2026-05-27 → 2026-06-24 - Fix wholesale employee portal: getEmployeeSessionAction + EmployeePortalClient - Fix 51 TypeScript errors (return type corruption, missing imports)
36 lines
893 B
PL/PgSQL
36 lines
893 B
PL/PgSQL
-- Create imports bucket if it doesn't exist
|
|
-- Note: Run this in Supabase dashboard or via CLI
|
|
-- supabase storage create contacts-imports --public
|
|
|
|
-- Create RPC function to process imports from bucket URL
|
|
CREATE OR REPLACE FUNCTION process_contact_import_from_url(
|
|
p_brand_id UUID,
|
|
p_file_url TEXT,
|
|
p_allow_opt_in_override BOOLEAN DEFAULT false
|
|
)
|
|
RETURNS JSONB
|
|
LANGUAGE plpgsql
|
|
SECURITY DEFINER
|
|
AS $$
|
|
DECLARE
|
|
v_result JSONB;
|
|
v_csv_text TEXT;
|
|
BEGIN
|
|
-- Fetch the CSV from the bucket URL
|
|
SELECT content INTO v_csv_text
|
|
FROM net.http_get(p_file_url);
|
|
|
|
-- Process the contacts (this would need to be implemented based on your CSV parsing logic)
|
|
-- For now, return a placeholder result
|
|
-- You would call your existing import logic here
|
|
|
|
v_result := jsonb_build_object(
|
|
'created', 0,
|
|
'updated', 0,
|
|
'skipped', 0,
|
|
'errors', 0
|
|
);
|
|
|
|
RETURN v_result;
|
|
END;
|
|
$$; |