aboutsummaryrefslogtreecommitdiff
path: root/src/server/ApiManagers/FireflyManager.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/ApiManagers/FireflyManager.ts')
-rw-r--r--src/server/ApiManagers/FireflyManager.ts23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/server/ApiManagers/FireflyManager.ts b/src/server/ApiManagers/FireflyManager.ts
index 160a94d40..e75ede9df 100644
--- a/src/server/ApiManagers/FireflyManager.ts
+++ b/src/server/ApiManagers/FireflyManager.ts
@@ -132,7 +132,8 @@ export default class FireflyManager extends ApiManager {
],
body: body,
})
- .then(response2 => response2.json().then(json => ({ seed: json.outputs?.[0]?.seed, url: json.outputs?.[0]?.image?.url })))
+ .then(response2 => response2.json())
+ .then(json => (json.error_code ? json : { seed: json.outputs?.[0]?.seed, url: json.outputs?.[0]?.image?.url }))
.catch(error => {
console.error('Error:', error);
return undefined;
@@ -297,13 +298,13 @@ export default class FireflyManager extends ApiManager {
_invalid(res, styleUrl.message);
throw new Error('Error uploading images to dropbox');
}
- this.uploadImageToDropbox(req.body.structure, req.user as DashUserModel)
- .then(structureUrl => {
- if (structureUrl instanceof Error) {
- _invalid(res, structureUrl.message);
+ this.uploadImageToDropbox(req.body.structureUrl, req.user as DashUserModel)
+ .then(dropboxStructureUrl => {
+ if (dropboxStructureUrl instanceof Error) {
+ _invalid(res, dropboxStructureUrl.message);
throw new Error('Error uploading images to dropbox');
}
- return { styleUrl, structureUrl };
+ return { styleUrl, structureUrl: dropboxStructureUrl };
})
.then(uploads =>
this.generateImageFromStructure(req.body.prompt, req.body.width, req.body.height, uploads.structureUrl, req.body.strength, req.body.presets, uploads.styleUrl)
@@ -332,10 +333,12 @@ export default class FireflyManager extends ApiManager {
subscription: '/queryFireflyImage',
secureHandler: ({ req, res }) =>
this.generateImage(req.body.prompt, req.body.width, req.body.height, req.body.seed).then(img =>
- DashUploadUtils.UploadImage(img?.url ?? '', undefined, img?.seed).then(info => {
- if (info instanceof Error) _invalid(res, info.message);
- else _success(res, info);
- })
+ img.error_code
+ ? _invalid(res, img.message)
+ : DashUploadUtils.UploadImage(img?.url ?? '', undefined, img?.seed).then(info => {
+ if (info instanceof Error) _invalid(res, info.message);
+ else _success(res, info);
+ })
),
});