Added time Ban and penalty
This commit is contained in:
@@ -117,6 +117,8 @@ router.patch("/:id", async (req, res) => {
|
||||
router.delete("/:id", async (req, res) => {
|
||||
const { id } = req.params;
|
||||
const bann = req.body?.bann as boolean;
|
||||
const reason = req.body?.reason as string;
|
||||
const until = req.body?.until as Date | null;
|
||||
|
||||
const requiredPermission = bann ? "ADMIN_USER" : "ADMIN_KICK";
|
||||
|
||||
@@ -146,14 +148,16 @@ router.delete("/:id", async (req, res) => {
|
||||
|
||||
io.to(`user:${aircraft.userId}`).emit("notification", {
|
||||
type: "admin-message",
|
||||
message: "Verbindung durch einen Administrator getrennt",
|
||||
message: `Du wurdest von ${getPublicUser(req.user).publicId} ${until ? `bis zum ${new Date(until).toLocaleString()} ` : ""} ${
|
||||
status === "ban" ? "gebannt" : "gekickt"
|
||||
}`,
|
||||
status,
|
||||
data: { admin: getPublicUser(req.user) },
|
||||
data: { admin: getPublicUser(req.user), reason },
|
||||
} as AdminMessage);
|
||||
|
||||
io.in(`user:${aircraft.userId}`).disconnectSockets(true);
|
||||
|
||||
if (bann) {
|
||||
if (bann && !until) {
|
||||
await prisma.user.update({
|
||||
where: { id: aircraft.userId },
|
||||
data: {
|
||||
@@ -163,6 +167,15 @@ router.delete("/:id", async (req, res) => {
|
||||
},
|
||||
});
|
||||
}
|
||||
await prisma.penalty.create({
|
||||
data: {
|
||||
userId: aircraft.userId,
|
||||
type: bann ? (until ? "TIME_BAN" : "BAN") : "KICK",
|
||||
until: until ? new Date(until) : null,
|
||||
reason: reason,
|
||||
createdUserId: req.user.id,
|
||||
},
|
||||
});
|
||||
|
||||
res.status(204).send();
|
||||
} catch (error) {
|
||||
|
||||
@@ -34,6 +34,8 @@ import { Request, Response } from "express";
|
||||
router.delete("/:id", async (req, res) => {
|
||||
const { id } = req.params;
|
||||
const bann = req.body?.bann as boolean;
|
||||
const reason = req.body?.reason as string;
|
||||
const until = req.body?.until as Date | null;
|
||||
|
||||
const requiredPermission = bann ? "ADMIN_USER" : "ADMIN_KICK";
|
||||
|
||||
@@ -63,14 +65,16 @@ router.delete("/:id", async (req, res) => {
|
||||
|
||||
io.to(`user:${dispatcher.userId}`).emit("notification", {
|
||||
type: "admin-message",
|
||||
message: "Verbindung durch einen Administrator getrennt",
|
||||
message: `Du wurdest von ${getPublicUser(req.user).publicId} ${until ? `bis zum ${new Date(until).toLocaleString()} ` : ""} ${
|
||||
status === "ban" ? "gebannt" : "gekickt"
|
||||
}`,
|
||||
status,
|
||||
data: { admin: getPublicUser(req.user) },
|
||||
data: { admin: getPublicUser(req.user), reason },
|
||||
} as AdminMessage);
|
||||
|
||||
io.in(`user:${dispatcher.userId}`).disconnectSockets(true);
|
||||
|
||||
if (bann) {
|
||||
if (bann && !until) {
|
||||
await prisma.user.update({
|
||||
where: { id: dispatcher.userId },
|
||||
data: {
|
||||
@@ -80,6 +84,15 @@ router.delete("/:id", async (req, res) => {
|
||||
},
|
||||
});
|
||||
}
|
||||
await prisma.penalty.create({
|
||||
data: {
|
||||
userId: dispatcher.userId,
|
||||
type: bann ? (until ? "TIME_BAN" : "BAN") : "KICK",
|
||||
until: until ? new Date(until) : null,
|
||||
reason: reason,
|
||||
createdUserId: req.user.id,
|
||||
},
|
||||
});
|
||||
|
||||
res.status(204).send();
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user