From 743a13ca545f0e03edb274143a7aae820cec7843 Mon Sep 17 00:00:00 2001 From: Yufan Sheng Date: Fri, 28 Jun 2024 13:05:53 +0800 Subject: [PATCH] feat: drop the duplicated comment user settings. --- options.ts | 2 -- src/helpers/db/query.ts | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/options.ts b/options.ts index cf2d102..5626ebe 100644 --- a/options.ts +++ b/options.ts @@ -67,7 +67,6 @@ const Options = z }), comments: z.object({ server: z.string().url().readonly(), - admins: z.array(z.number()), size: z.number().default(10).readonly(), avatar: z.object({ mirror: z.string().url().readonly(), @@ -185,7 +184,6 @@ const options: z.input = { }, comments: { server: 'https://comment.yufan.me', - admins: [3], size: 10, avatar: { mirror: 'https://weavatar.com/avatar', diff --git a/src/helpers/db/query.ts b/src/helpers/db/query.ts index 0614533..2590a07 100644 --- a/src/helpers/db/query.ts +++ b/src/helpers/db/query.ts @@ -2,7 +2,7 @@ import { db } from '@/helpers/db/pool'; import { atk_comments, atk_likes, atk_pages, atk_users } from '@/helpers/db/schema'; import { makeToken, urlJoin } from '@/helpers/tools'; import options from '@/options'; -import { and, desc, eq, isNull, notInArray, sql } from 'drizzle-orm'; +import { and, desc, eq, isNull, not, sql } from 'drizzle-orm'; export interface Comment { title: string; @@ -53,9 +53,9 @@ export const latestComments = async (): Promise => { authorLink: atk_users.link, }) .from(atk_comments) - .leftJoin(atk_pages, eq(atk_comments.page_key, atk_pages.key)) - .leftJoin(atk_users, eq(atk_comments.user_id, atk_users.id)) - .where(and(notInArray(atk_comments.user_id, options.settings.comments.admins), eq(atk_comments.is_pending, false))) + .innerJoin(atk_pages, eq(atk_comments.page_key, atk_pages.key)) + .innerJoin(atk_users, eq(atk_comments.user_id, atk_users.id)) + .where(and(not(eq(atk_users.email, options.author.email)), eq(atk_comments.is_pending, false))) .orderBy(desc(atk_comments.created_at)) .limit(options.settings.sidebar.comment);