Skip to content

Full Summary Status Matrix

status / paymentStatusIDLEAWAITING_PAYMENTAUTHORIZEDPAIDFAILEDCANCELLED
DRAFT
IN_PROGRESS
SUMMARIZED
FAILED

DRAFT — case is created, but Summary hasn't started

DRAFT x IDLE: ✅

DRAFT and IDLE are the default statuses, so it's always true. It means that nothing has happened yet to the case. Users can do whatever they want with the case: upload files, delete files, change settings, etc.

DRAFT x AWAITING_PAYMENT: ✅

Once user decides to pay AND { targetPrice: { $gt: 0 } }, we create a payment session, getting a session.url for the payment page from Stripe, set it to the paymentSessionUrl field, and change the paymentStatus to AWAITING_PAYMENT. Besides that, we set paymentInitiatedAt to the current date and time.

DRAFT x AUTHORIZED: ❌

It's not possible. After a successful payment we set { status: "IN_PROGRESS", paymentStatus: "AUTHORIZED" } in (post.stripeWebhook.ts:66:13).

DRAFT x PAID: ❌

It's not possible. { paymentStatus: "PAID" } is set only when Stripe sends a webhook after { status: 'SUMMARIZED' }.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: DRAFT x FAILED: ✅

It's possible when Stripe sends a webhook about a failed payment. In that moment we just set paymentStatus to FAILED.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: DRAFT x CANCELLED: ✅

It's possible when Stripe sends a webhook about a cancelled payment. In that moment we just set paymentStatus to CANCELLED.

IN_PROGRESS — AI is working on the summary

IN_PROGRESS x IDLE: ❌

It's not possible. We can't start summarization before payment.

IN_PROGRESS x AWAITING_PAYMENT: ❌

It's not possible. We can't start summarization before payment.

IN_PROGRESS x AUTHORIZED: ✅

It's possible. After a successful payment we set { status: "IN_PROGRESS", paymentStatus: "AUTHORIZED" } in (post.stripeWebhook.ts:66:13).

IN_PROGRESS x PAID: ❌

It's not possible. { paymentStatus: "PAID" } is set only when Stripe sends a webhook after { status: 'SUMMARIZED' }.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: IN_PROGRESS x FAILED: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: IN_PROGRESS x CANCELLED: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

SUMMARIZED — AI completed summarization

SUMMARIZED x IDLE: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

SUMMARIZED x AWAITING_PAYMENT: ❌

It's impossible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

SUMMARIZED x AUTHORIZED: ✅

It's possible. In both FULL cases because we have next transition:

ts
// 1. User initiates a payment (if targetPrice > 0)
{ targetPrice: { $gt: 0 }, status: "DRAFT", paymentStatus: "AWAITING_PAYMENT" }
// or
{ targetPrice: { $eq: 0 }, status: "IN_PROGRESS", paymentStatus: "PAID" }

// 2. User paid for the summary (if targetPrice > 0)
{ targetPrice: { $gt: 0 }, status: "IN_PROGRESS", paymentStatus: "AUTHORIZED" }

// 3. We start summarization

// 🤹‍♀️ MAGIC HAPPENS HERE 🤡

// 4. We complete summarization
{ status: "SUMMARIZED" }

// 5. We capture payment (if targetPrice > 0)
{ targetPrice: { $gt: 0 }, paymentStatus: "PAID" }
SUMMARIZED x PAID: Paid ✅

It's possible. Stripe sends a webhook about a successful capture. We set { status: "SUMMARIZED", paymentStatus: "PAID" }.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: SUMMARIZED x FAILED: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: SUMMARIZED x CANCELLED: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

FAILED — AI failed to summarize

FAILED x IDLE: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

FAILED x AWAITING_PAYMENT: ❌

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

FAILED x AUTHORIZED: ✅

It's possible. Summary can be failed after it's paid.

FAILED x PAID: ❌

It's not possible. We don't capture payment after a failed summary. (Looks like we should unhold the payment in Stripe.)

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: FAILED x FAILED

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.

⚠️ ⚠️ ⚠️ TODO ⚠️ ⚠️ ⚠️: FAILED x CANCELLED

It's not possible. We don't start any summary before { paymentStatus: "AUTHORIZED" }.