feat: drop the duplicated comment user settings.
This commit is contained in:
parent
e2064c2fa9
commit
5bfb23d4e4
@ -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',
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user