feat(api): add endpoints for blocking/unblocking a specific user

This commit is contained in:
parent 8bf78a0494
commit 6afc547f8e
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C
2 changed files with 38 additions and 0 deletions

@ -0,0 +1,19 @@
import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn";
import { User } from "~/models/user";
export default eventHandler(async (ev) => {
isLoggedIn(ev);
let idee = parseInt(getRouterParam(ev, "id")!);
if (isNaN(idee))
throw createError({
statusCode: 400,
});
await User.findOneAndUpdate(
{ _id: ev.context.currentUser!._id },
{
$addToSet: {
blocked: idee,
},
},
);
});

@ -0,0 +1,19 @@
import isLoggedIn from "~/lib/server/middlewareButNotReally/isLoggedIn";
import { User } from "~/models/user";
export default eventHandler(async (ev) => {
isLoggedIn(ev);
let idee = parseInt(getRouterParam(ev, "id")!);
if (isNaN(idee))
throw createError({
statusCode: 400,
});
await User.findOneAndUpdate(
{ _id: ev.context.currentUser!._id },
{
$pull: {
blocked: idee,
},
},
);
});