1
0
Fork 0

fix: suspending works again, clarify bans

dufisgsd
Lea 2023-08-11 16:46:35 +02:00
parent 32726dc7c6
commit 7360333523
Signed by: lea
GPG Key ID: 1BAFFE8347019C42
2 changed files with 14 additions and 9 deletions

View File

@ -204,7 +204,7 @@ export function UserActions({ user, bot }: { user: User; bot?: Bot }) {
)
}
>
Suspend
{userDraft.flags === 1 ? "Unsuspend" : "Suspend"}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
@ -225,13 +225,18 @@ export function UserActions({ user, bot }: { user: User; bot?: Bot }) {
<AlertDialogTitle>
Are you sure you want to ban this user?
</AlertDialogTitle>
<AlertDialogDescription className="text-red-700">
<AlertDialogDescription>
All messages sent by this user will be deleted immediately.
<br className="text-base/8" />
<span className="text-red-700">
This action is irreversible!
</span>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className="hover:bg-red-700 transition-all"
onClick={() =>
banUser(user._id)
.then(() => {

View File

@ -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",