mirror of
https://github.com/ProjectSegfault/website.git
synced 2024-11-30 02:32:51 +05:30
fix
This commit is contained in:
parent
e4333a8b4c
commit
6bcfb0b356
@ -2,9 +2,6 @@ import type { Actions } from "./$types";
|
|||||||
import Joi from "joi";
|
import Joi from "joi";
|
||||||
import { fail } from "@sveltejs/kit";
|
import { fail } from "@sveltejs/kit";
|
||||||
import { db } from "$lib/server/db";
|
import { db } from "$lib/server/db";
|
||||||
import dayjs from "dayjs";
|
|
||||||
|
|
||||||
const collection = db.collection("announcements");
|
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
add: async ({ request, locals }) => {
|
add: async ({ request, locals }) => {
|
||||||
@ -29,6 +26,8 @@ export const actions: Actions = {
|
|||||||
created: now
|
created: now
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const collection = db.collection("announcements");
|
||||||
|
|
||||||
await collection.deleteMany({});
|
await collection.deleteMany({});
|
||||||
|
|
||||||
await collection.insertOne(data);
|
await collection.insertOne(data);
|
||||||
@ -42,6 +41,7 @@ export const actions: Actions = {
|
|||||||
if (!await locals.getSession()) {
|
if (!await locals.getSession()) {
|
||||||
return fail(401, { deleteError: true, deleteMessage: "You must be logged in to delete an announcement." });
|
return fail(401, { deleteError: true, deleteMessage: "You must be logged in to delete an announcement." });
|
||||||
} else {
|
} else {
|
||||||
|
const collection = db.collection("announcements");
|
||||||
|
|
||||||
await collection.deleteMany({});
|
await collection.deleteMany({});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user