// import Inject, { ServiceProvider } from "@entity-access/entity-access/dist/di/di.js"; // import SocialMailContext from "../../../../server/model/SocialMailContext.js"; // import TempFileService from "../../../../server/storage/TempFileService.js"; // import ImageConverterService from "../../../../server/services/image-converter/ImageConverterService.js"; // import { TempFileResult } from "@entity-access/server-pages/dist/Content.js"; // import Page from "@entity-access/server-pages/dist/Page.js"; // import CacheService from "../../../../server/services/cache/CacheService.js"; // import TimeSpan from "@entity-access/entity-access/dist/types/TimeSpan.js"; // import FileConversionService from "../../../../server/services/convert/FileConversionService.js"; // import AppFile from "../../../../server/model/entities/AppFile.js"; // export default class extends Page { // @Inject // private tfs: TempFileService; // @Inject // private cacheService: CacheService; // @Inject // private db: SocialMailContext; // @Inject // private signerService: SignerService; // async run() { // const type = this.childPath[0]; // // we will not convert as BigInt might have loss of data // const fileID = this.childPath[1] as unknown as number; // const fileContentID = this.childPath[2] as unknown as number; // const signature = this.childPath[3]; // const expiry = this.childPath[4]; // // verify hash .... // this.signerService.signer().verify({ appFileID: fileID , fileContentID }, signature, expiry); // this.db.verifyFilters = true; // const fc = await this.db.appFiles // .where({ fileID, fileContentID }, // (x, p) => x.fileContentID === p.fileContentID // && x.appFileID === p.fileID) // .include((x) => x.fileContent) // .firstOrFail(); // this.db.verifyFilters = false; // this.db.raiseEvents = false; // this.cacheControl = "public, max-age=2592000, immutable"; // let file = await this.tfs.downloadFileContent(fc.fileContent, fc); // const key = this.request.path; // const ttl = TimeSpan.fromDays(30); // // transform here... // if (/^(size|jpg|png|webp|gif|face\-circle)\(/i.test(type)) { // file = await this.cacheService.get({ key, ttl, factory: async () => { // // resize... // const ics = ServiceProvider.resolve(this, ImageConverterService); // return await ics.transform(type, file, this.childPath[this.childPath.length-1] ); // } }); // } else if (/^(pdf|html|webm)$/i.test(type)) { // file = await this.cacheService.get({ key, ttl, factory: async () => { // const ics = ServiceProvider.resolve(this, FileConversionService); // return await ics[type.toLowerCase()](file, this.childPath[this.childPath.length-1] ); // } }); // } // return new TempFileResult( // file, // { // contentDisposition: type === "download" // ? "attachment" // : "inline", // immutable: true, // etag: false // } // ); // } // }