mirror of
https://github.com/BillyOutlast/drop.git
synced 2026-02-04 08:41:17 +01:00
fix: news frontend
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
import { defineEventHandler, createError } from "h3";
|
||||
import aclManager from "~/server/internal/acls";
|
||||
import newsManager from "~/server/internal/news";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const userId = await event.context.session.getUserId(event);
|
||||
if (!userId) {
|
||||
export default defineEventHandler(async (h3) => {
|
||||
const allowed = await aclManager.allowSystemACL(h3, ["news:delete"]);
|
||||
if (!allowed)
|
||||
throw createError({
|
||||
statusCode: 401,
|
||||
message: "Unauthorized",
|
||||
statusCode: 403,
|
||||
});
|
||||
}
|
||||
|
||||
const id = event.context.params?.id;
|
||||
const id = h3.context.params?.id;
|
||||
if (!id) {
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
|
||||
@@ -45,23 +45,27 @@ class NewsManager {
|
||||
return await prisma.article.findMany({
|
||||
where: {
|
||||
AND: [
|
||||
{
|
||||
tags: {
|
||||
some: { OR: options.tags?.map((e) => ({ name: e })) ?? [] },
|
||||
},
|
||||
},
|
||||
{
|
||||
title: {
|
||||
search: options.search
|
||||
},
|
||||
description: {
|
||||
search: options.search
|
||||
},
|
||||
content: {
|
||||
search: options.search
|
||||
}
|
||||
}
|
||||
],
|
||||
options.tags
|
||||
? {
|
||||
tags: {
|
||||
some: { OR: options.tags?.map((e) => ({ name: e })) ?? [] },
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
options.search
|
||||
? {
|
||||
title: {
|
||||
search: options.search,
|
||||
},
|
||||
description: {
|
||||
search: options.search,
|
||||
},
|
||||
content: {
|
||||
search: options.search,
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
].filter((e) => e !== undefined),
|
||||
},
|
||||
take: options?.take || 10,
|
||||
skip: options?.skip || 0,
|
||||
@@ -75,6 +79,7 @@ class NewsManager {
|
||||
displayName: true,
|
||||
},
|
||||
},
|
||||
tags: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -89,6 +94,7 @@ class NewsManager {
|
||||
displayName: true,
|
||||
},
|
||||
},
|
||||
tags: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user