Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 1x 2x 2x 2x 2x 2x | /**
* Job ownership map (Abacus Studio Phase 2a, #8.3).
*
* The print service stays the single source of truth for job state; these
* rows only record which connection/user submitted a job so `jobs/*` proxy
* reads can be authorized and doorbell rings resolved to the owning tenant.
*/
import { and, eq } from 'drizzle-orm'
import { db, schema } from '@/db'
import type { PrintJob } from '@/db/schema'
export async function recordJobOwnership(input: {
jobId: string
connectionId: string
userId: string
printerId: string
}): Promise<void> {
await db.insert(schema.printJobs).values(input).onConflictDoNothing()
}
export async function getOwnedJob(userId: string, jobId: string): Promise<PrintJob | undefined> {
return db.query.printJobs.findFirst({
where: and(eq(schema.printJobs.jobId, jobId), eq(schema.printJobs.userId, userId)),
})
}
|