Honor the share-link miss limit before querying, and keep Escape inside the access menu.

This commit is contained in:
adilallo committed 2026-11-21 11:56:34 -07:00
1 parent 75649a9a42
commit 1b3d055c81
8 files changed
+189 -19

No files matched your search

+9 -2
View File
@@ -3,7 +3,10 @@ import { headers } from "next/headers";
import { notFound } from "next/navigation";
import messages from "../../../../messages/en/index";
import { isShareSlug } from "../../../../lib/sharePaths";
import { getReadablePublishedRule } from "../../../../lib/server/publishedRules";
import {
SHARE_LOOKUP_MISS_INTERVAL_MS,
getReadablePublishedRule,
} from "../../../../lib/server/publishedRules";
import { rateLimitKey } from "../../../../lib/server/rateLimit";
import { getSessionUser } from "../../../../lib/server/session";
import { parsePublishedDocumentForCommunityRuleDisplay } from "../../../../lib/create/publishedDocumentToDisplaySections";
@@ -27,7 +30,11 @@ async function clientIp(): Promise<string> {
async function loadSharedRule(shareSlug: string) {
const ip = await clientIp();
if (!isShareSlug(shareSlug)) {
rateLimitKey(`share-lookup-miss:${ip}`, 1_000);
const limited = rateLimitKey(
`share-lookup-miss:${ip}`,
SHARE_LOOKUP_MISS_INTERVAL_MS,
);
if (!limited.ok) return null;
return null;
}
const user = await getSessionUser();