sqlite
This commit is contained in:
@@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user