mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
fix: update tool installation checks and refactor stdout JSON parsing in AI modules
This commit is contained in:
@@ -100,7 +100,7 @@ export function isFeatureInstalled(bundleId: string): boolean {
|
||||
|
||||
export function isToolInstalled(toolId: string): boolean {
|
||||
const bundleId = TOOL_BUNDLE_MAP[toolId];
|
||||
if (!bundleId) return false;
|
||||
if (!bundleId) return true;
|
||||
return isFeatureInstalled(bundleId);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,17 @@ const settingsSchema = z.object({
|
||||
*/
|
||||
export function registerRestorePhoto(app: FastifyInstance) {
|
||||
app.post("/api/v1/tools/restore-photo", async (request: FastifyRequest, reply: FastifyReply) => {
|
||||
if (!isToolInstalled("restore-photo")) {
|
||||
const bundle = getBundleForTool("restore-photo");
|
||||
return reply.status(501).send({
|
||||
error: "Feature not installed",
|
||||
code: "FEATURE_NOT_INSTALLED",
|
||||
feature: "photo-restoration",
|
||||
featureName: bundle?.name ?? "Photo Restoration",
|
||||
estimatedSize: bundle?.estimatedSize ?? "unknown",
|
||||
});
|
||||
}
|
||||
|
||||
let fileBuffer: Buffer | null = null;
|
||||
let filename = "image";
|
||||
let settingsRaw: string | null = null;
|
||||
@@ -69,18 +80,6 @@ export function registerRestorePhoto(app: FastifyInstance) {
|
||||
return reply.status(400).send({ error: `Invalid image: ${validation.reason}` });
|
||||
}
|
||||
|
||||
// Guard: check if the photo restoration feature bundle is installed
|
||||
if (!isToolInstalled("restore-photo")) {
|
||||
const bundle = getBundleForTool("restore-photo");
|
||||
return reply.status(501).send({
|
||||
error: "Feature not installed",
|
||||
code: "FEATURE_NOT_INSTALLED",
|
||||
feature: "photo-restoration",
|
||||
featureName: bundle?.name ?? "Photo Restoration",
|
||||
estimatedSize: bundle?.estimatedSize ?? "unknown",
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const settings = settingsSchema.parse(settingsRaw ? JSON.parse(settingsRaw) : {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user