feature: rooms and events implemented on the backend

This commit is contained in:
Andy Burke 2025-06-27 17:54:04 -07:00
parent df00324e24
commit 85024c6e62
29 changed files with 1659 additions and 115 deletions

View file

@ -1,4 +1,4 @@
import { CANNED_RESPONSES } from '../../../../utils/canned_responses.ts';
import * as CANNED_RESPONSES from '../../../../utils/canned_responses.ts';
import { get_session, get_user, PRECHECK_TABLE, require_user } from '../../../../utils/prechecks.ts';
export const PERMISSIONS: Record<string, (req: Request, meta: Record<string, any>) => Promise<boolean>> = {};
@ -6,15 +6,9 @@ export const PRECHECKS: PRECHECK_TABLE = {};
// GET /api/users/me - Get the current user
PRECHECKS.GET = [get_session, get_user, require_user, (_req: Request, meta: Record<string, any>): Response | undefined => {
const can_read_self = meta.user_permissions?.permissions.includes('self.read');
const can_read_self = meta.user?.permissions.includes('self.read');
const has_permission = can_read_self;
console.dir({
meta,
can_read_self,
has_permission
});
if (!has_permission) {
if (!can_read_self) {
return CANNED_RESPONSES.permission_denied();
}
}];