1
0
Fork 0

fix: suspending works again, clarify bans

user-stream
Lea 2023-08-11 16:46:35 +02:00 committed by insert
parent 72db810066
commit 6cfe0a2ffa
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> </AlertDialogAction>
</AlertDialogFooter> </AlertDialogFooter>
</AlertDialogContent> </AlertDialogContent>
@ -225,13 +225,18 @@ export function UserActions({ user, bot }: { user: User; bot?: Bot }) {
<AlertDialogTitle> <AlertDialogTitle>
Are you sure you want to ban this user? Are you sure you want to ban this user?
</AlertDialogTitle> </AlertDialogTitle>
<AlertDialogDescription className="text-red-700"> <AlertDialogDescription>
This action is irreversible! 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> </AlertDialogDescription>
</AlertDialogHeader> </AlertDialogHeader>
<AlertDialogFooter> <AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction <AlertDialogAction
className="hover:bg-red-700 transition-all"
onClick={() => onClick={() =>
banUser(user._id) banUser(user._id)
.then(() => { .then(() => {

View File

@ -7,10 +7,6 @@ import mongo, {
ChannelInvite, ChannelInvite,
createDM, createDM,
fetchAccountById, fetchAccountById,
fetchChannels,
fetchMembershipsByUser,
fetchMessages,
fetchUserById,
findDM, findDM,
} from "./db"; } from "./db";
import { publishMessage, sendChatMessage } from "./redis"; import { publishMessage, sendChatMessage } from "./redis";
@ -29,7 +25,6 @@ import {
User, User,
} from "revolt-api"; } from "revolt-api";
import { checkPermission } from "./accessPermissions"; import { checkPermission } from "./accessPermissions";
import { redirect } from "next/navigation";
export async function sendAlert(userId: string, content: string) { export async function sendAlert(userId: string, content: string) {
await checkPermission("users/create/alert", userId, { content }); 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)) { for (const topic of memberships.map((x) => x._id.server)) {
await publishMessage(topic, { await publishMessage(topic, {
type: "UserUpdate", type: "UserUpdate",