Evidence Submission

This document describes the Evidence Submission feature, allowing Taskers to submit proof of work for their tasks.

1. Overview

Once a Tasker accepts a Referee’s request (or is matched), the Task enters a state where evidence can be submitted. The evidence consists of a text description and up to 5 image assets.

The submission process uses Cloudflare R2 for image storage and Supabase for metadata and status management.

2. Upload Sequence

The following sequence diagram illustrates the secure upload flow, including:

  1. Fetching Task details (to verify permissions).

  2. Generating a presigned URL via Edge Function (which securely holds R2 credentials and public domain logic).

  3. Direct upload to R2 (bypassing the application server for heavy lifting).

  4. Submitting metadata (including R2 keys and public URLs) to the database via a secure RPC.

Diagram

3. Key Components

3.1. Edge Function: generate-upload-url

  • Responsibility:

    • Validates user authentication and Task ownership.

    • Generates a unique R2 Object Key (evidence/…​).

    • Generates a recursive 10-minute Presigned PUT URL.

    • Constructs the public_url using the R2_PUBLIC_DOMAIN environment variable.

  • Security: Ensures only the Tasker can upload files for their specific task.

3.2. RPC: submit_evidence

  • Responsibility:

    • Validates that the Judgement status is awaiting_evidence or in_review.

    • Atomically transitions the Judgement status to in_review.

    • Inserts records into task_evidences and task_evidence_assets.

  • Concurrency: Uses database transactions to ensure data consistency.

3.3. Client: EvidenceRepository

  • Responsibility:

    • Orchestrates the flow: Pick ImagesGet URLUpload to R2Submit Metadata.

    • Handles connection to the Edge Function using the Supabase SDK (ensuring correct environment routing).