feat: drop the duplicated comment user settings.

This commit is contained in:
Yufan Sheng 2024-06-28 13:05:53 +08:00
parent e2064c2fa9
commit 5bfb23d4e4
Signed by: syhily
GPG Key ID: 9D18A22A7DCD5A9B
2 changed files with 4 additions and 6 deletions

View File

@ -67,7 +67,6 @@ const Options = z
}), }),
comments: z.object({ comments: z.object({
server: z.string().url().readonly(), server: z.string().url().readonly(),
admins: z.array(z.number()),
size: z.number().default(10).readonly(), size: z.number().default(10).readonly(),
avatar: z.object({ avatar: z.object({
mirror: z.string().url().readonly(), mirror: z.string().url().readonly(),
@ -185,7 +184,6 @@ const options: z.input<typeof Options> = {
}, },
comments: { comments: {
server: 'https://comment.yufan.me', server: 'https://comment.yufan.me',
admins: [3],
size: 10, size: 10,
avatar: { avatar: {
mirror: 'https://weavatar.com/avatar', mirror: 'https://weavatar.com/avatar',

View File

@ -2,7 +2,7 @@ import { db } from '@/helpers/db/pool';
import { atk_comments, atk_likes, atk_pages, atk_users } from '@/helpers/db/schema'; import { atk_comments, atk_likes, atk_pages, atk_users } from '@/helpers/db/schema';
import { makeToken, urlJoin } from '@/helpers/tools'; import { makeToken, urlJoin } from '@/helpers/tools';
import options from '@/options'; 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 { export interface Comment {
title: string; title: string;
@ -53,9 +53,9 @@ export const latestComments = async (): Promise<Comment[]> => {
authorLink: atk_users.link, authorLink: atk_users.link,
}) })
.from(atk_comments) .from(atk_comments)
.leftJoin(atk_pages, eq(atk_comments.page_key, atk_pages.key)) .innerJoin(atk_pages, eq(atk_comments.page_key, atk_pages.key))
.leftJoin(atk_users, eq(atk_comments.user_id, atk_users.id)) .innerJoin(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))) .where(and(not(eq(atk_users.email, options.author.email)), eq(atk_comments.is_pending, false)))
.orderBy(desc(atk_comments.created_at)) .orderBy(desc(atk_comments.created_at))
.limit(options.settings.sidebar.comment); .limit(options.settings.sidebar.comment);