From 7360333523949c0a239632e66da241157634b60b Mon Sep 17 00:00:00 2001 From: Lea Date: Fri, 11 Aug 2023 16:46:35 +0200 Subject: [PATCH] fix: suspending works again, clarify bans --- components/pages/inspector/UserActions.tsx | 11 ++++++++--- lib/actions.ts | 12 ++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/components/pages/inspector/UserActions.tsx b/components/pages/inspector/UserActions.tsx index 2b7da86..2936bc7 100644 --- a/components/pages/inspector/UserActions.tsx +++ b/components/pages/inspector/UserActions.tsx @@ -204,7 +204,7 @@ export function UserActions({ user, bot }: { user: User; bot?: Bot }) { ) } > - Suspend + {userDraft.flags === 1 ? "Unsuspend" : "Suspend"} @@ -225,13 +225,18 @@ export function UserActions({ user, bot }: { user: User; bot?: Bot }) { Are you sure you want to ban this user? - - This action is irreversible! + + All messages sent by this user will be deleted immediately. +
+ + This action is irreversible! +
Cancel banUser(user._id) .then(() => { diff --git a/lib/actions.ts b/lib/actions.ts index a8db87f..2081b6e 100644 --- a/lib/actions.ts +++ b/lib/actions.ts @@ -7,10 +7,6 @@ import mongo, { ChannelInvite, createDM, fetchAccountById, - fetchChannels, - fetchMembershipsByUser, - fetchMessages, - fetchUserById, findDM, } from "./db"; import { publishMessage, sendChatMessage } from "./redis"; @@ -29,7 +25,6 @@ import { User, } from "revolt-api"; import { checkPermission } from "./accessPermissions"; -import { redirect } from "next/navigation"; export async function sendAlert(userId: string, content: string) { await checkPermission("users/create/alert", userId, { content }); @@ -321,7 +316,12 @@ export async function suspendUser(userId: string) { } ); - const memberships = await fetchMembershipsByUser(userId); + const memberships = await mongo() + .db("revolt") + .collection<{ _id: { user: string; server: string } }>("server_members") + .find({ "_id.user": userId }) + .toArray(); + for (const topic of memberships.map((x) => x._id.server)) { await publishMessage(topic, { type: "UserUpdate",