Skip to content
refs
12 lines · 648 BRaw
1import type { Outcome, Pull } from "@refs/backend/contract";
2import { formText } from "./session";
3
4export 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`. */
7export 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}