Add account based multiplayer hosting and bug report retention
This commit is contained in:
38
lib/bug-retention.ts
Normal file
38
lib/bug-retention.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { BugReportRecord } from "../shared/bug-reports";
|
||||
import type { LinearSupportClient } from "./linear-support-client";
|
||||
|
||||
export async function purgeClosedBugReport(
|
||||
id: string,
|
||||
closedAt: string,
|
||||
deps: {
|
||||
record: () => Promise<BugReportRecord | null>;
|
||||
linear: Pick<LinearSupportClient, "issue" | "remove">;
|
||||
begin: () => Promise<boolean>;
|
||||
reopen: () => Promise<void>;
|
||||
removeFiles: (paths: string[]) => Promise<void>;
|
||||
finish: () => Promise<void>;
|
||||
now?: () => number;
|
||||
},
|
||||
) {
|
||||
const report = await deps.record();
|
||||
if (
|
||||
!report ||
|
||||
report.state !== "done" ||
|
||||
report.closed_at !== closedAt ||
|
||||
!report.delete_after ||
|
||||
Date.parse(report.delete_after) > (deps.now ?? Date.now)()
|
||||
)
|
||||
return;
|
||||
if (!report.purge_started_at) {
|
||||
const issue = await deps.linear.issue(id);
|
||||
if (issue && issue.state?.type !== "completed") {
|
||||
await deps.reopen();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!(await deps.begin())) return;
|
||||
// Keep the local retry record until BOTH external deletions are confirmed.
|
||||
await deps.linear.remove(id);
|
||||
await deps.removeFiles([`${id}/input`, `${id}/screenshot.webp`]);
|
||||
await deps.finish();
|
||||
}
|
||||
Reference in New Issue
Block a user