12 lines · 648 BRaw
| 1 | import type { Outcome, Pull } from "@refs/backend/contract"; |
| 2 | import { formText } from "./session"; |
| 3 | |
| 4 | export const THREAD_INTENTS = new Set(["thread-reply", "thread-resolve", "thread-reopen"]); |
| 5 | |
| 6 | /** Runs a review thread card's reply, resolve or reopen against `pull`. */ |
| 7 | export function threadAction(pull: Pull, intent: string, form: FormData): Promise<Outcome> { |
| 8 | const thread = Number(formText(form, "thread")); |
| 9 | if (intent === "thread-resolve") return pull.resolveThread(thread); |
| 10 | if (intent === "thread-reopen") return pull.reopenThread(thread); |
| 11 | return pull.replyToThread(thread, formText(form, "body"), formText(form, "assign") === "1"); |
| 12 | } |