feat(core): config, job queue, range media serving, feature composition
Adds aclRepo to @stc/db for canView. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ea18f18b4f
commit
7f33169487
12 files changed
+533
No files matched your search
@@ -5,3 +5,4 @@ export { notesRepo, type Note, type NoteInput } from "./repos/notes";
|
||||
export { attemptsRepo, type Attempt } from "./repos/attempts";
|
||||
export { libraryRepo, type Collection } from "./repos/library";
|
||||
export { jobsRepo, type JobPatch } from "./repos/jobs";
|
||||
export { aclRepo, type AclEntry } from "./repos/acl";
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { Db } from "../connect";
|
||||
|
||||
export interface AclEntry { principal_type: "user" | "group"; principal_id: string }
|
||||
|
||||
export function aclRepo(db: Db) {
|
||||
return {
|
||||
async listForCourse(courseId: string): Promise<AclEntry[]> {
|
||||
const rows = await db.sql`SELECT principal_type, principal_id FROM course_acl WHERE course_id = ${courseId} ORDER BY principal_type, principal_id`;
|
||||
return rows.map((r: AclEntry) => ({ principal_type: r.principal_type, principal_id: r.principal_id }));
|
||||
},
|
||||
async isAuthor(courseId: string, userId: string): Promise<boolean> {
|
||||
const rows = await db.sql`SELECT 1 AS x FROM course_authors WHERE course_id = ${courseId} AND user_id = ${userId}`;
|
||||
return rows.length > 0;
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user