Files
Nexumi/apps/webui/src/app/api/guilds/[guildId]/feeds/route.ts
smueller 08af99ed52 Implement premium features and GDPR compliance in bot and WebUI
- Added new models for premium tier configurations and assignments, enabling feature limits for free and premium users.
- Introduced GDPR deletion logging and commands for user data management.
- Enhanced logging configuration with retention days for audit logs.
- Updated bot commands and job processing to include new premium and GDPR functionalities.
- Improved localization with new keys for premium features and GDPR commands in both English and German.
- Added UI components for managing premium settings and logging retention in the WebUI.
2026-07-22 16:59:23 +02:00

48 lines
1.5 KiB
TypeScript

import { SocialFeedDashboardCreateSchema } from '@nexumi/shared';
import { type NextRequest, NextResponse } from 'next/server';
import { requireGuildAccess, toApiErrorResponse } from '@/lib/auth';
import { writeDashboardAudit } from '@/lib/audit';
import { createFeed, FeedPremiumError, listFeeds } from '@/lib/module-configs/feeds';
import { prisma } from '@/lib/prisma';
interface RouteParams {
params: Promise<{ guildId: string }>;
}
export async function GET(_request: NextRequest, { params }: RouteParams) {
const { guildId } = await params;
try {
await requireGuildAccess(guildId);
const feeds = await listFeeds(guildId);
return NextResponse.json({ feeds });
} catch (error) {
return toApiErrorResponse(error);
}
}
export async function POST(request: NextRequest, { params }: RouteParams) {
const { guildId } = await params;
try {
const session = await requireGuildAccess(guildId);
const body = await request.json();
const input = SocialFeedDashboardCreateSchema.parse(body);
const feed = await createFeed(guildId, input);
await writeDashboardAudit(prisma, {
guildId,
actorUserId: session.user.id,
action: 'feeds.create',
path: `/dashboard/${guildId}/feeds`,
after: feed
});
return NextResponse.json(feed, { status: 201 });
} catch (error) {
if (error instanceof FeedPremiumError) {
return NextResponse.json({ error: error.code }, { status: 403 });
}
return toApiErrorResponse(error);
}
}