import { readSettings, writeSettings } from '../core/rooms.ts' import { handle, kodyCtx, params } from '../runtime.ts' /** * Read or update package-wide defaults. With no fields it only reads. * * @param input.caps - Default caps for new rooms: membersPerRoom, postsPerMemberPerHour, * messageBytes, liveRoomsPerCreator, postsPerRoomPerDay, inviteTtlHours. * @param input.cleanup - `{ enabled, closedRoomRetentionDays, idleRoomRetentionDays }` (off by default). * @returns `{ status: 'ok', caps, cleanup }` * @example * import settings from 'kody:@kody/rooms/settings' * await settings({ caps: { postsPerMemberPerHour: 120 } }) */ export default async function settings(input: unknown) { return handle(async () => { const p = params(input, ['caps', 'cleanup']) const ctx = kodyCtx() const result = p.caps == null && p.cleanup == null ? await readSettings(ctx) : await writeSettings(ctx, p) return { status: 'ok' as const, ...result } }) }