feat : copy youtube studio
CI / Verify (push) Successful in 2m8s
CI / Build immutable images and deploy (push) Successful in 2m39s

This commit is contained in:
2026-10-08 03:26:00 +07:00 Unverified
parent 9bc710c94b
commit b665fe7497
16 changed files with 196 additions and 46 deletions
+12 -4
View File
@@ -98,10 +98,11 @@ async function revisionImages(ids: string[], db: Reader = getDb()) {
export async function listComments(options: {
viewer: CommentViewer | null; target?: string; rootId?: string; id?: string; cursor?: string | null;
sort?: string; inbox?: boolean; status?: string; unanswered?: boolean;
sort?: string; inbox?: boolean; grouped?: boolean; status?: string; unanswered?: boolean;
}): Promise<CommentPage> {
const { viewer } = options;
if (options.inbox) requireCommentAdmin(viewer);
const grouped = Boolean(options.inbox && options.grouped && !options.id && !options.rootId);
const conditions: SQL[] = [];
if (options.id) conditions.push(eq(comments.id, commentId(options.id)));
if (options.target) {
@@ -114,14 +115,21 @@ export async function listComments(options: {
if (context.comment.rootId) throw new HttpError(400, "root-required");
if (options.target && context.destination.target !== options.target) throw new HttpError(404, "comment-not-found");
conditions.push(eq(comments.rootId, options.rootId));
} else if (!options.inbox && !options.id) conditions.push(isNull(comments.rootId));
} else if (grouped || (!options.inbox && !options.id)) conditions.push(isNull(comments.rootId));
if (!viewer?.admin) {
conditions.push(sql`coalesce(${root.hidden}, false) = false`, publicTarget);
if (!options.rootId) conditions.push(eq(comments.hidden, false));
if (!options.rootId && !options.id) conditions.push(or(isNull(comments.deletedAt), sql`${replyCount} > 0`)!);
}
if (options.status === "hidden") conditions.push(or(eq(comments.hidden, true), eq(root.hidden, true))!);
if (options.status === "visible") conditions.push(eq(comments.hidden, false), sql`coalesce(${root.hidden}, false) = false`, isNull(comments.deletedAt));
if (grouped) {
if (options.status === "hidden") conditions.push(or(eq(comments.hidden, true), sql`exists (
select 1 from ${comments} reply where reply.root_id = ${comments.id} and reply.hidden)`)!);
if (options.status === "visible") conditions.push(eq(comments.hidden, false), or(isNull(comments.deletedAt), sql`exists (
select 1 from ${comments} reply where reply.root_id = ${comments.id} and not reply.hidden and reply.deleted_at is null)`)!);
} else {
if (options.status === "hidden") conditions.push(or(eq(comments.hidden, true), eq(root.hidden, true))!);
if (options.status === "visible") conditions.push(eq(comments.hidden, false), sql`coalesce(${root.hidden}, false) = false`, isNull(comments.deletedAt));
}
if (options.unanswered) conditions.push(isNull(comments.rootId), isNull(comments.deletedAt), sql`not exists (
select 1 from ${comments} reply join ${users} author on author.id = reply.author_id
where reply.root_id = ${comments.id} and author.role = 'admin' and author.email_verified and not reply.hidden and reply.deleted_at is null)`);