refactor: events to a pure stream instead of being part of topics

NOTE: tests are passing, but the client is broken
This commit is contained in:
Andy Burke 2025-11-08 11:55:57 -08:00
parent c34069066d
commit a5707e2f81
31 changed files with 934 additions and 686 deletions

View file

@ -1,8 +1,9 @@
import { getCookies } from '@std/http/cookie';
import { SESSIONS } from '../models/session.ts';
import { verifyTotp } from './totp.ts';
import { USERS } from '../models/user.ts';
import { USER, USERS } from '../models/user.ts';
import * as CANNED_RESPONSES from './canned_responses.ts';
import { EVENT } from '../models/event.ts';
export type PRECHECK = (req: Request, meta: Record<string, any>) => Promise<Response | undefined> | Response | undefined;
export type PRECHECK_TABLE = Record<string, PRECHECK[]>;
@ -41,3 +42,7 @@ export function require_user(
return CANNED_RESPONSES.permission_denied();
}
}
export function user_has_write_permission_for_event(user: USER, event: EVENT) {
return user.permissions.includes('events.create.' + event.type) || (Deno.env.get('DENO_ENV') === 'test' && event.type === 'test');
}