feat: use file hashes and title_id hashes for data retrieval

This commit is contained in:
mrjvs 2025-09-03 19:57:38 +02:00
parent fa2b048015
commit ff085aadf5
4 changed files with 10 additions and 7 deletions

View File

@ -15,6 +15,7 @@ const TaskSchema = new mongoose.Schema<ITask, TaskModel, ITaskMethods>({
enum: ['open'] // TODO - What else is there?
},
title_id: String,
title_id_hash: String,
description: Number,
created: BigInt,
updated: BigInt

View File

@ -6,11 +6,12 @@ import { getCdnFileAsStream, streamFileToResponse } from '@/cdn';
const npdi = express.Router();
npdi.get('/p01/data/1/:titleHash/:dataID/:fileHash', async (request, response) => {
const { dataID } = request.params;
npdi.get('/p01/data/1/:titleIdHash/:dataId/:fileHash', async (request, response) => {
const { dataId, fileHash } = request.params;
const file = await File.findOne({
data_id: dataID
data_id: dataId,
hash: fileHash
});
if (!file) {
return response.sendStatus(404);

View File

@ -10,12 +10,12 @@ import { File } from '@/models/file';
const npts = express.Router();
npts.get('/p01/tasksheet/:id/:hash/:taskId', async (request, response) => {
const { id, taskId } = request.params;
npts.get('/p01/tasksheet/:id/:titleIdHash/:taskId', async (request, response) => {
const { titleIdHash, taskId } = request.params;
const task = await Task.findOne({
title_id: id,
id: taskId
id: taskId,
title_id_hash: titleIdHash
});
if (!task) {
return response.sendStatus(404);

View File

@ -8,6 +8,7 @@ export interface ITask {
creator_pid: number;
status: 'open'; // TODO - Make this a union. What else is there?
title_id: string;
title_id_hash: string;
description: string;
created: bigint;
updated: bigint;