feature: first pass on replies
refactor: move more smarts in the smartforms around
This commit is contained in:
parent
e1bb07a138
commit
ab63d4ba8d
6 changed files with 343 additions and 181 deletions
|
|
@ -2,7 +2,7 @@ import lurid from '@andyburke/lurid';
|
|||
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../../../utils/prechecks.ts';
|
||||
import { TOPIC, TOPICS } from '../../../../../models/topic.ts';
|
||||
import * as CANNED_RESPONSES from '../../../../../utils/canned_responses.ts';
|
||||
import { EVENT, get_events_collection_for_topic } from '../../../../../models/event.ts';
|
||||
import { EVENT, get_events_collection_for_topic, VALIDATE_EVENT } from '../../../../../models/event.ts';
|
||||
import parse_body from '../../../../../utils/bodyparser.ts';
|
||||
import { FSDB_COLLECTION, FSDB_SEARCH_OPTIONS, WALK_ENTRY } from '@andyburke/fsdb';
|
||||
import * as path from '@std/path';
|
||||
|
|
@ -172,6 +172,15 @@ export async function POST(req: Request, meta: Record<string, any>): Promise<Res
|
|||
|
||||
event.id = `${event.type}:${lurid()}`;
|
||||
|
||||
const errors = VALIDATE_EVENT(event);
|
||||
if (errors) {
|
||||
return Response.json({
|
||||
errors
|
||||
}, {
|
||||
status: 400
|
||||
});
|
||||
}
|
||||
|
||||
await events.create(event);
|
||||
|
||||
return Response.json(event, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue