From 0fed34ecbbea1388bc87c3fb11366ab043bd9723 Mon Sep 17 00:00:00 2001 From: NiallJoeMaher Date: Tue, 17 Nov 2026 11:03:16 +0000 Subject: [PATCH 1/8] chore: clear all security advisories, update dependencies, and fix what surfaced Security and dependencies - npm audit at the root goes from 87 advisories (5 critical, 17 high) to 0. - In-range updates across the board; nodemailer 7 -> 10, sharp 0.33 -> 0.35, aws-cdk-lib -> 2.277 (cdk/), and TipTap 2 -> 3, which has no patched 2.x release. Editor behaviour is pinned to what it was, and TipTap JSON post bodies now render through the server entry point. - Drop packages only the unused old editor needed, and the CDK packages the root never imported. Duplicate vercel.app site - On production, *.vercel.app hosts 308 to the project's production domain. /api, preview deploys and forks are left alone. Moderation - System reports raised by the nightly review are now listed, counted and dismissible in the admin queue, for posts and comments. - The cron raises at most one system report per post or comment. Feed sources - Admin Sync ingests into the live posts table through a shared module that the feed:fetch script also uses, instead of the legacy tables. - Creating a source sets its slug and linked author profile. - Untrusted article pages are fetched through one guarded fetch that validates every redirect hop and caps the body. Cleanup - Remove tRPC procedures with no caller, the unused comment router, the old editor, unused helpers, and unreferenced files including a 17 MB binary. - Search links use the shared URL builder; /feed.xml returns 500 on failure; canonicals on three static pages; Lambda runtimes to Node 22; actions/cache v4; .mcp.json untracked. --- .github/workflows/e2e-tests.yml | 2 +- .gitignore | 6 + .mcp.json | 27 - E2E Overview.md | 36 - app/(admin)/admin/_client.tsx | 7 +- app/(admin)/admin/moderation/_client.tsx | 127 +- app/(app)/(tsandcs)/privacy/page.mdx | 18 +- app/(app)/code-of-conduct/page.tsx | 1 + app/(app)/feed/feedQuery.ts | 8 +- .../how-to-get-mentorship-top-picks/page.mdx | 2 +- .../page.mdx | 4 +- .../page.mdx | 2 +- app/(marketing)/about/page.tsx | 1 + app/(marketing)/advertise/page.tsx | 1 + app/api/admin/sync-feeds/route.ts | 310 +- app/api/cron/daily-review/route.ts | 10 +- app/feed.xml/route.ts | 4 +- bin/act | Bin 17657664 -> 0 bytes cdk/lambdas/avatarResize/package-lock.json | 2218 +-- cdk/lambdas/avatarResize/package.json | 2 +- cdk/lambdas/dailyReview/index.ts | 2 +- cdk/lambdas/promoteScheduled/index.ts | 2 +- cdk/lambdas/rssFetcher/index.ts | 9 +- cdk/lambdas/rssFetcher/package-lock.json | 1353 +- cdk/lambdas/uploadResize/package-lock.json | 2218 +-- cdk/lambdas/uploadResize/package.json | 2 +- cdk/lib/cron-stack.ts | 8 +- cdk/lib/storage-stack.ts | 4 +- cdk/package-lock.json | 11326 ++++------------ cdk/package.json | 4 +- components/ContentDetail/PostBody.test.ts | 75 + components/ContentDetail/PostBody.tsx | 3 +- components/Feed/Filters.tsx | 8 +- .../ImageDetailsModal/ImageDetailsModal.tsx | 149 - components/PostEditor/extensions/index.ts | 15 +- .../PostEditor/hooks/useArticleEditor.ts | 10 +- components/PromptService/PromptLink.tsx | 4 +- components/Terminal/TerminalShell.tsx | 4 +- components/editor/editor/RenderPost.tsx | 22 - .../editor/editor/components/bubble-menu.tsx | 112 - .../editor/components/image-resizer.tsx | 64 - .../editor/components/link-selector.tsx | 106 - .../editor/components/node-selector.tsx | 99 - components/editor/editor/default-content.tsx | 203 - .../disable-heading-text-style-shortcuts.tsx | 18 - components/editor/editor/extensions/index.tsx | 159 - .../editor/extensions/render-extensions.ts | 4 +- .../editor/extensions/slash-command.tsx | 371 - .../editor/extensions/update-youtube.ts | 18 - components/editor/editor/index.tsx | 49 - .../editor/editor/plugins/upload-images.tsx | 159 - components/editor/editor/props.ts | 55 - components/editor/icons/font-default.tsx | 20 - components/editor/icons/font-mono.tsx | 21 - components/editor/icons/font-serif.tsx | 21 - components/editor/icons/github.tsx | 14 - components/editor/icons/index.tsx | 3 - components/editor/icons/loading-circle.tsx | 22 - components/editor/icons/magic.tsx | 30 - components/editor/primitives/leaflet.tsx | 87 - components/editor/primitives/popover.tsx | 30 - config/site_settings.ts | 18 - eslint.config.mjs | 6 + lib/og-image.ts | 127 - next.config.js | 21 + package-lock.json | 10242 ++++++-------- package.json | 66 +- schema/additionalUserDetails.ts | 78 - schema/comment.ts | 112 - schema/content.ts | 22 - schema/feed.ts | 70 - schema/post.ts | 99 - schema/report.ts | 10 + scripts/create-source-users.ts | 42 +- scripts/fetch-rss.ts | 321 +- seed.yml | 2 - server/api/router/admin.ts | 211 +- server/api/router/comment.ts | 790 -- server/api/router/content.ts | 290 +- server/api/router/discussion.ts | 4 +- server/api/router/feed.ts | 644 +- server/api/router/index.ts | 9 +- server/api/router/post.ts | 821 +- server/api/router/report.ts | 48 +- server/api/router/search.ts | 7 +- server/api/router/utils.ts | 24 +- server/controllers/post.ts | 20 - server/lib/fetchPage.test.ts | 54 +- server/lib/fetchPage.ts | 111 +- server/lib/posts.ts | 129 +- server/lib/reportedPosts.test.ts | 118 + server/lib/reportedPosts.ts | 86 + server/lib/rssIngest.test.ts | 205 + server/lib/rssIngest.ts | 312 + server/lib/sourceUser.test.ts | 21 + server/lib/sourceUser.ts | 51 + server/lib/tags.ts | 36 - utils/editor.ts | 21 - utils/readingTime.ts | 5 - vitest.config.ts | 2 +- 100 files changed, 10275 insertions(+), 24649 deletions(-) delete mode 100644 .mcp.json delete mode 100644 E2E Overview.md delete mode 100755 bin/act create mode 100644 components/ContentDetail/PostBody.test.ts delete mode 100644 components/ImageDetailsModal/ImageDetailsModal.tsx delete mode 100644 components/editor/editor/RenderPost.tsx delete mode 100644 components/editor/editor/components/bubble-menu.tsx delete mode 100644 components/editor/editor/components/image-resizer.tsx delete mode 100644 components/editor/editor/components/link-selector.tsx delete mode 100644 components/editor/editor/components/node-selector.tsx delete mode 100644 components/editor/editor/default-content.tsx delete mode 100644 components/editor/editor/extensions/disable-heading-text-style-shortcuts.tsx delete mode 100644 components/editor/editor/extensions/index.tsx delete mode 100644 components/editor/editor/extensions/slash-command.tsx delete mode 100644 components/editor/editor/extensions/update-youtube.ts delete mode 100644 components/editor/editor/index.tsx delete mode 100644 components/editor/editor/plugins/upload-images.tsx delete mode 100644 components/editor/editor/props.ts delete mode 100644 components/editor/icons/font-default.tsx delete mode 100644 components/editor/icons/font-mono.tsx delete mode 100644 components/editor/icons/font-serif.tsx delete mode 100644 components/editor/icons/github.tsx delete mode 100644 components/editor/icons/index.tsx delete mode 100644 components/editor/icons/loading-circle.tsx delete mode 100644 components/editor/icons/magic.tsx delete mode 100644 components/editor/primitives/leaflet.tsx delete mode 100644 components/editor/primitives/popover.tsx delete mode 100644 lib/og-image.ts delete mode 100644 schema/additionalUserDetails.ts delete mode 100644 schema/comment.ts delete mode 100644 seed.yml delete mode 100644 server/api/router/comment.ts delete mode 100644 server/controllers/post.ts create mode 100644 server/lib/reportedPosts.test.ts create mode 100644 server/lib/reportedPosts.ts create mode 100644 server/lib/rssIngest.test.ts create mode 100644 server/lib/rssIngest.ts create mode 100644 server/lib/sourceUser.test.ts create mode 100644 server/lib/sourceUser.ts delete mode 100644 server/lib/tags.ts delete mode 100644 utils/editor.ts delete mode 100644 utils/readingTime.ts diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 79da92312..12de22ca8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -59,7 +59,7 @@ jobs: cache: "npm" - name: Cache Playwright browsers - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ~/.cache/ms-playwright key: ${{ runner.os }}-playwright-${{ hashFiles('**/package-lock.json') }} diff --git a/.gitignore b/.gitignore index 3bb96bd26..8320e48d4 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,9 @@ logs/ .claude/ .cursor/ .aider* + +# Local MCP server config (may hold personal API keys) +.mcp.json + +# Written by `next dev` +AGENTS.md diff --git a/.mcp.json b/.mcp.json deleted file mode 100644 index a86d7c2c4..000000000 --- a/.mcp.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "mcpServers": { - "context7": { - "command": "npx", - "args": ["-y", "@upstash/context7-mcp"], - "env": { - "CONTEXT7_API_KEY": "ctx7sk-1d829fe1-62b2-4697-b7f4-673ae5047efd" - } - }, - "puppeteer": { - "command": "npx", - "args": ["-y", "puppeteer-mcp-server"], - "env": {} - }, - "next-devtools": { - "command": "npx", - "args": ["-y", "next-devtools-mcp@latest"] - }, - "sequential-thinking": { - "command": "npx", - "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"] - }, - "Sentry": { - "url": "https://mcp.sentry.dev/mcp/assemble-pro/javascript-nextjs" - } - } -} diff --git a/E2E Overview.md b/E2E Overview.md deleted file mode 100644 index ba0146638..000000000 --- a/E2E Overview.md +++ /dev/null @@ -1,36 +0,0 @@ -# End-to-End Testing with Playwright - -To run the end-to-end tests using Playwright, you need to configure your environment and follow these steps: - -### Session and User Setup - -First, you need to add your E2E test user to your locally running database. Do this by running the following script if you haven't already: - -```bash -npm run db:seed -``` - -This will create a user and session for your E2E tests. Details of the E2E user created can be seen in `drizzle/seedE2E.ts`. - -### Running the Tests - -You can run the end-to-end tests using one of the following commands: - -For headless mode: - -```bash -npx playwright test -``` - -For UI mode: - -```bash -npx playwright test --ui -``` - -### Additional E2E constants - -- **E2E_USER_ONE_SESSION_ID**: This is the session token UUID for one E2E user. -- **E2E_USER_TWO_SESSION_ID**: This is the session token UUID for another E2E user. -- **E2E_USER_ONE_ID**: The user ID of one of the E2E users. -- **E2E_USER_TWO_ID**: The user ID of another E2E user. diff --git a/app/(admin)/admin/_client.tsx b/app/(admin)/admin/_client.tsx index 35c33d90a..daf0d6273 100644 --- a/app/(admin)/admin/_client.tsx +++ b/app/(admin)/admin/_client.tsx @@ -12,12 +12,7 @@ import { import { api } from "@/server/trpc/react"; type StatTone = - | "accent" - | "success" - | "warning" - | "danger" - | "info" - | "neutral"; + "accent" | "success" | "warning" | "danger" | "info" | "neutral"; const toneClasses: Record = { accent: "bg-accent/10 text-accent", diff --git a/app/(admin)/admin/moderation/_client.tsx b/app/(admin)/admin/moderation/_client.tsx index 285bcc28e..cbfece7e7 100644 --- a/app/(admin)/admin/moderation/_client.tsx +++ b/app/(admin)/admin/moderation/_client.tsx @@ -122,12 +122,30 @@ const ModerationQueue = () => { }, }); + // System (auto-flagged) reports live in their own table with their own ids, + // so they are dismissed through a separate mutation from member reports. + const { mutate: dismissSystemReport, isPending: isDismissingSystem } = + api.report.dismissSystem.useMutation({ + onSuccess: () => { + toast.success("Report dismissed"); + utils.admin.listReportedPosts.invalidate(); + utils.admin.listFlaggedComments.invalidate(); + utils.report.getCounts.invalidate(); + }, + onError: () => { + toast.error("Failed to dismiss report"); + }, + }); + // Auto-moderation queue (posts awaiting review). const inReview = api.admin.listInReview.useQuery(); - // Live posts that have been flagged by users (open reports on published posts). + // Live posts with open reports, from members or the nightly review. const reportedPosts = api.admin.listReportedPosts.useQuery(); + // Comments flagged by the nightly review. + const flaggedComments = api.admin.listFlaggedComments.useQuery(); + const { mutate: moderatePost, isPending: isModerating } = api.admin.moderatePost.useMutation({ onSuccess: (_data, variables) => { @@ -167,7 +185,10 @@ const ModerationQueue = () => { }; // Dismiss all open reports for a reported-live post (the post stays published). - const handleDismissReportedPost = (reportIds: number[]) => { + const handleDismissReportedPost = ( + reportIds: number[], + systemReportIds: number[], + ) => { reportIds.forEach((reportId) => reviewReport({ reportId, @@ -175,6 +196,7 @@ const ModerationQueue = () => { actionTaken: "Reports dismissed by admin", }), ); + systemReportIds.forEach((reportId) => dismissSystemReport({ reportId })); utils.admin.listReportedPosts.invalidate(); }; @@ -373,7 +395,7 @@ const ModerationQueue = () => { - {/* Reported (live) — published posts users have flagged */} + {/* Reported (live) — published posts flagged by users or the nightly review */}

@@ -427,6 +449,11 @@ const ModerationQueue = () => { {reasonLabels[post.latestReason as ReportReason] ?? post.latestReason} + {post.systemReportIds.length > 0 && ( + + Auto-flagged + + )} {post.latestDetails && ( {post.latestDetails} @@ -457,8 +484,98 @@ const ModerationQueue = () => { +

+ + + ))} + +
+ + {/* Flagged comments — comments the nightly review has auto-flagged */} +
+
+

+ {"// "}flagged comments +

+ + {flaggedComments.data?.length ?? 0} flagged + +
+ + {flaggedComments.isLoading && ( +

Loading…

+ )} + + {!flaggedComments.isLoading && + (flaggedComments.data?.length ?? 0) === 0 && ( +

+ {"// no flagged comments"} +

+ )} + +
+ {flaggedComments.data?.map((comment) => ( +
+
+
+

{comment.body}

+

+ @{comment.authorUsername ?? "unknown"} on{" "} + {comment.parentTitle || "Untitled"} ·{" "} + {getRelativeTime(comment.reportedAt)} + {comment.isDeleted ? " · deleted" : ""} +

+
+ + {reasonLabels[comment.reason as ReportReason] ?? + comment.reason} + + + Auto-flagged + + {comment.details && ( + + {comment.details} + + )} +
+
+
+ {comment.href && ( + + + View + + )} +