diff --git a/app/page.tsx b/app/page.tsx
index 639249f..67cfc48 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -1,5 +1,6 @@
import { Button } from "@/components/ui/button";
import { Comic_Neue } from "next/font/google";
+import Link from "next/link";
const comicNeue = Comic_Neue({ subsets: ["latin"], weight: "700" });
@@ -9,7 +10,9 @@ export default function Home() {
className={`${comicNeue.className} flex flex-col justify-center items-center gap-4 h-[100vh]`}
>
revolt admin panel
-
+
+
+
-
-
+
-
+ */}
-
-
+
-
+ */}
-1) throw "TODO: ACL";
+
const messageId = ulid();
let dm = await findDM(PLATFORM_MOD_ID, userId);
@@ -47,6 +49,8 @@ export async function createStrike(
givenReason: string,
additionalContext: string
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
const strike: AccountStrike & { moderator_id: string } = {
_id: ulid(),
user_id: userId,
@@ -72,6 +76,8 @@ Further violations will result in suspension or a permanent ban depending on sev
}
export async function updateReportNotes(reportId: string, notes: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("safety_reports")
@@ -86,6 +92,8 @@ export async function updateReportNotes(reportId: string, notes: string) {
}
export async function resolveReport(reportId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
const $set = {
status: "Resolved",
closed_at: new Date().toISOString(),
@@ -102,6 +110,8 @@ export async function resolveReport(reportId: string) {
}
export async function rejectReport(reportId: string, reason: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
const $set = {
status: "Rejected",
rejection_reason: reason,
@@ -119,6 +129,8 @@ export async function rejectReport(reportId: string, reason: string) {
}
export async function reopenReport(reportId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
const $set = {
status: "Created",
} as Report;
@@ -140,6 +152,8 @@ export async function reopenReport(reportId: string) {
}
export async function closeReportsByUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("safety_reports")
@@ -160,6 +174,8 @@ export async function closeReportsByUser(userId: string) {
}
export async function disableAccount(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo()
.db("revolt")
.collection("accounts")
@@ -171,6 +187,8 @@ export async function disableAccount(userId: string) {
}
export async function suspendUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await disableAccount(userId);
await mongo()
@@ -201,6 +219,8 @@ export async function suspendUser(userId: string) {
}
export async function updateUserBadges(userId: string, badges: number) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo().db("revolt").collection("users").updateOne(
{
_id: userId,
@@ -226,6 +246,8 @@ export async function updateUserBadges(userId: string, badges: number) {
}
export async function wipeUser(userId: string, flags = 4) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
// retrieve messages, dm channels, relationships, server memberships
const backup = {
_event: "wipe",
@@ -321,10 +343,14 @@ export async function wipeUser(userId: string, flags = 4) {
}
export async function banUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await wipeUser(userId, 4);
}
export async function unsuspendUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await restoreAccount(userId);
await mongo()
@@ -343,6 +369,8 @@ export async function unsuspendUser(userId: string) {
}
export async function updateServerFlags(serverId: string, flags: number) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo().db("revolt").collection("servers").updateOne(
{
_id: serverId,
@@ -368,6 +396,8 @@ export async function updateServerDiscoverability(
serverId: string,
state: boolean
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo()
.db("revolt")
.collection("servers")
@@ -385,6 +415,8 @@ export async function updateServerDiscoverability(
}
export async function updateBotDiscoverability(botId: string, state: boolean) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo()
.db("revolt")
.collection("bots")
@@ -402,6 +434,8 @@ export async function updateBotDiscoverability(botId: string, state: boolean) {
}
export async function restoreAccount(accountId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo()
.db("revolt")
.collection("accounts")
@@ -418,6 +452,8 @@ export async function restoreAccount(accountId: string) {
}
export async function queueAccountDeletion(accountId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
const twoWeeksFuture = new Date();
twoWeeksFuture.setDate(twoWeeksFuture.getDate() + 14);
@@ -443,6 +479,8 @@ export async function queueAccountDeletion(accountId: string) {
}
export async function cancelAccountDeletion(accountId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
await mongo()
.db("revolt")
.collection("accounts")
diff --git a/lib/db.ts b/lib/db.ts
index a495d8a..ad6ae56 100644
--- a/lib/db.ts
+++ b/lib/db.ts
@@ -28,6 +28,8 @@ function mongo() {
export default mongo;
export async function fetchBotById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("bots")
@@ -76,6 +78,8 @@ export type Account = {
};
export async function fetchAccountById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("accounts")
@@ -91,6 +95,8 @@ export async function fetchAccountById(id: string) {
}
export async function fetchSessionsByAccount(accountId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("sessions")
@@ -109,6 +115,8 @@ export async function fetchSessionsByAccount(accountId: string) {
}
export async function fetchUserById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("users")
@@ -116,6 +124,8 @@ export async function fetchUserById(id: string) {
}
export async function fetchUsersById(ids: string[]) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("users")
@@ -124,6 +134,8 @@ export async function fetchUsersById(ids: string[]) {
}
export async function fetchChannelById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("channels")
@@ -131,6 +143,8 @@ export async function fetchChannelById(id: string) {
}
export async function fetchChannels(query: Filter) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("channels")
@@ -142,6 +156,8 @@ export async function updateLastMessageId(
channelId: string,
messageId: string
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("channels")
@@ -149,6 +165,8 @@ export async function updateLastMessageId(
}
export async function findDM(user_a: string, user_b: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("channels")
@@ -165,6 +183,8 @@ export async function createDM(
userB: string,
lastMessageId?: string
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
const newChannel: Channel & { channel_type: "DirectMessage" } = {
_id: ulid(),
channel_type: "DirectMessage",
@@ -191,6 +211,8 @@ export async function createDM(
}
export async function fetchServerById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("servers")
@@ -198,6 +220,8 @@ export async function fetchServerById(id: string) {
}
export async function fetchServers(query: Filter) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("servers")
@@ -206,6 +230,8 @@ export async function fetchServers(query: Filter) {
}
export async function fetchMessageById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("messages")
@@ -213,6 +239,8 @@ export async function fetchMessageById(id: string) {
}
export async function fetchMessages(query: Filter, limit = 50) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("messages")
@@ -223,6 +251,8 @@ export async function fetchMessages(query: Filter, limit = 50) {
export async function fetchReports(
query: Filter = { status: "Created" }
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("safety_reports")
@@ -235,6 +265,8 @@ export async function fetchReports(
}
export async function fetchReportById(id: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("safety_reports")
@@ -242,6 +274,8 @@ export async function fetchReportById(id: string) {
}
export async function fetchMembershipsByUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection<{ _id: { user: string; server: string } }>("server_members")
@@ -252,6 +286,8 @@ export async function fetchMembershipsByUser(userId: string) {
export async function fetchSnapshots(
query: Filter<{ _id: string; report_id: string; content: SnapshotContent }>
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection<{ _id: string; report_id: string; content: SnapshotContent }>(
@@ -262,6 +298,8 @@ export async function fetchSnapshots(
}
export async function fetchSnapshotsByReport(reportId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection<{ content: SnapshotContent }>("safety_snapshots")
@@ -271,6 +309,8 @@ export async function fetchSnapshotsByReport(reportId: string) {
}
export async function fetchStrikesByUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("safety_strikes")
@@ -286,6 +326,8 @@ export async function fetchStrikesByUser(userId: string) {
}
export async function fetchBotsByUser(userId: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("revolt")
.collection("bots")
@@ -299,6 +341,8 @@ export type EmailClassification = {
};
export async function fetchAuthifierEmailClassification(provider: string) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await mongo()
.db("authifier")
.collection("email_classification")
diff --git a/lib/redis.ts b/lib/redis.ts
index 9d67416..75b2d8a 100644
--- a/lib/redis.ts
+++ b/lib/redis.ts
@@ -25,10 +25,14 @@ export async function publishMessage(
topic: string,
message: ProtocolV1["server"]
) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
return await (await redis()).publish(topic, JSON.stringify(message));
}
export async function sendChatMessage(message: Message, ephermal = false) {
+ if (Math.random() > -1) throw "TODO: ACL";
+
if (!ephermal) {
await mongo()
.db("revolt")