Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

✨ Allow content from trusted creators when flagged by moderator (#2223)

Luke Vella352e8a13a728
diff --git a/apps/web/src/features/moderation/index.ts b/apps/web/src/features/moderation/index.ts
index 025bc18c9..8edb97569 100644
--- a/apps/web/src/features/moderation/index.ts
+++ b/apps/web/src/features/moderation/index.ts
@@ -26,9 +26,11 @@ const safeResult: ModerationResult = {
export async function moderateContent({
userId,
content,
+ trusted = false,
}: {
userId: string;
content: Record<string, string>;
+ trusted?: boolean;
}): Promise<ModerationResult> {
// Skip moderation if the feature is disabled in environment
if (env.MODERATION_ENABLED !== "true") {
@@ -69,6 +71,7 @@ export async function moderateContent({
subject: `Content ${result.verdict} by moderation`,
text: [
`User ID: ${userId}`,
+ `Trusted: ${trusted ? "Yes" : "No"}`,
`Verdict: ${result.verdict}`,
`Reason: ${result.reason}`,
"--------------------------------",
@@ -76,6 +79,14 @@ export async function moderateContent({
].join("\n\n"),
}),
);
+
+ if (trusted) {
+ logger.info(
+ { userId },
+ "Content flagged but user is trusted, allowing through",
+ );
+ return safeResult;
+ }
}
return result;
diff --git a/apps/web/src/trpc/routers/polls.ts b/apps/web/src/trpc/routers/polls.ts
index b10093cf9..f791a8db5 100644
--- a/apps/web/src/trpc/routers/polls.ts
+++ b/apps/web/src/trpc/routers/polls.ts
@@ -11,6 +11,7 @@ import { getPolls } from "@/features/poll/data";
import { canUserManagePoll } from "@/features/poll/helpers";
import { hasPollAdminAccess } from "@/features/poll/query";
import { formatEventDateTime } from "@/features/scheduled-event/utils";
+import { getActiveSpaceForUser } from "@/features/space/data";
import { dayjs } from "@/lib/dayjs";
import { getEmailClient } from "@/utils/emails";
import { createIcsEvent } from "@/utils/ics";
@@ -187,6 +188,11 @@ export const polls = router({
.use(requireUserMiddleware)
.use(createRateLimitMiddleware("create_poll", 20, "1 h"))
.mutation(async ({ ctx, input }) => {
+ const activeSpace = ctx.user.isGuest
+ ? null
+ : await getActiveSpaceForUser(ctx.user.id);
+ const isPro = activeSpace?.tier === "pro";
+
const moderation = await moderateContent({
userId: ctx.user.id,
content: {
@@ -194,6 +200,7 @@ export const polls = router({
Description: input.description || "",
Location: input.location || "",
},
+ trusted: isPro,
});
if (moderation.verdict !== "safe") {
@@ -379,6 +386,11 @@ export const polls = router({
});
}
+ const activeSpace = ctx.user.isGuest
+ ? null
+ : await getActiveSpaceForUser(ctx.user.id);
+ const isPro = activeSpace?.tier === "pro";
+
const moderation = await moderateContent({
userId: ctx.user.id,
content: {
@@ -386,6 +398,7 @@ export const polls = router({
Description: input.description || "",
Location: input.location || "",
},
+ trusted: isPro,
});
if (moderation.verdict !== "safe") {