This commit is contained in:
seb
2026-09-22 07:25:16 +02:00
parent 4ed6260e91
commit cca131d83a
148 changed files with 5343 additions and 3466 deletions

View File

@@ -1,20 +1,20 @@
import { GET_CATEGORY_ID_BY_HASH } from '../../providers/mssql/queries/pic.js';
import { GET_CATEGORY_ID_BY_HASH as MSSQL_GET } from '../../providers/mssql/queries/pic.js';
import { GET_CATEGORY_ID_BY_HASH as SQLITE_GET } from '../../providers/sqlite3/queries/pic.js';
import resolveCategoryAccess from '../category/resolveCategoryAccess.js';
import makeRunner from '../runner.js';
export default function resolvePicAccess(pool) {
const access = resolveCategoryAccess(pool);
export default function resolvePicAccess(provider) {
const access = resolveCategoryAccess(provider);
const sql = provider?.dialect === 'sqlite3' ? SQLITE_GET : MSSQL_GET;
return async (googleAuthId, fullHash) => {
const result = await pool
.request()
.input('hash', fullHash)
.query(GET_CATEGORY_ID_BY_HASH);
return async (googleAuthId, fullHash, tx) => {
const result = await makeRunner(provider, tx).query(sql, { hash: fullHash });
const categoryId = result.recordset[0]?.categoryId;
const categoryId = result.rows[0]?.categoryId;
if (!categoryId) {
throw new Error('Image not found');
}
await access(googleAuthId, categoryId);
await access(googleAuthId, categoryId, tx);
};
}