feat: file blocks
Pull request / title (pull_request) Successful in 1s
CI / test (pull_request) Successful in 1m8s
CI / image (apps/api/Dockerfile, t5de-hub-api) (pull_request) Skipped
CI / image (apps/web/Dockerfile, t5de-hub-web) (pull_request) Skipped

Moderators block a file network-wide by its sha256, from a product's files or the console's new Blocks tab, which
first shows the products using it. Blocking removes those products (their creators are told and may appeal), puts
a `block` change in the changes feed of every catalog hosting it, and refuses uploads with it; moderators see who
tried. Unblocking lets it in again; the products it removed stay removed until restored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
dhkatzandClaude Opus 5.5 committed 2026-11-05 14:32:08 -08:00
1 parent 7299e10b08
commit ba423f32d8
18 files changed
+4074 -10

No files matched your search

+21 -1
View File
@@ -20,7 +20,7 @@ import { cleanHTML, maxDescription } from "./html";
import type { ImvuClient } from "./imvu";
import type { Signer } from "./keys";
const { catalog, catalogChange, catalogMember, product, productInfoChange, productRevision, hosting, library, roleAssignment, user } =
const { catalog, catalogChange, catalogMember, fileBlock, product, productInfoChange, productRevision, hosting, library, roleAssignment, user } =
schema;
export type Catalog = typeof catalog.$inferSelect;
@@ -63,6 +63,17 @@ export class ProductError extends Error {
}
}
/** An upload with a blocked file (docs/products.md): refused, and the route audits who tried. */
export class BlockedUpload extends ProductError {
constructor(
readonly personId: string,
readonly catalogId: string,
readonly files: FileEntry[],
) {
super(409, "blocked", "This upload has a file T5DE blocks.");
}
}
const base32 = "abcdefghijklmnopqrstuvwxyz234567";
export const newProductID = () =>
[...crypto.getRandomValues(new Uint8Array(10))].map((b) => base32[b & 31]).join("");
@@ -260,6 +271,15 @@ export class Products {
const parent = Number.isSafeInteger(body.parent) && body.parent > 0 ? body.parent : 0;
const notes = (typeof body.notes === "string" ? body.notes.trim() : "").slice(0, 2000);
const personId = claims.sub;
const blocked = new Set(
(
await this.db
.select({ sha256: fileBlock.sha256 })
.from(fileBlock)
.where(inArray(fileBlock.sha256, [...new Set(files.map((f) => f.sha256))]))
).map((b) => b.sha256),
);
if (blocked.size) throw new BlockedUpload(personId, c.id, files.filter((f) => blocked.has(f.sha256)));
const made = await this.db.transaction(async (tx) => {
let p: Product;