diff options
author | 0xCmdrKeen <98132670+0xCmdrKeen@users.noreply.github.com> | 2023-10-17 11:58:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 19:58:51 +0100 |
commit | a3b01c2dd24ccf1d2a4fa8c89df7c4c861fc52ac (patch) | |
tree | 7225b4ace5f8919f04b442c0b39146459645d239 /app | |
parent | Bump actions/checkout from 3 to 4 (#80) (diff) | |
download | ferdium-server-a3b01c2dd24ccf1d2a4fa8c89df7c4c861fc52ac.tar.gz ferdium-server-a3b01c2dd24ccf1d2a4fa8c89df7c4c861fc52ac.tar.zst ferdium-server-a3b01c2dd24ccf1d2a4fa8c89df7c4c861fc52ac.zip |
Fix bugs in data import from Ferdium app (#82)
* Fixed misspelled field names
* Fixed broken tests
* Ensure service.settings and workspace.data are not JSON encoded twice
* Accept both snake_case and camelCase input files
* More tests for JSON fields
* Add filename to assertion messages
Diffstat (limited to 'app')
-rw-r--r-- | app/Controllers/Http/Dashboard/TransferController.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/app/Controllers/Http/Dashboard/TransferController.ts b/app/Controllers/Http/Dashboard/TransferController.ts index a005c1b..b113e50 100644 --- a/app/Controllers/Http/Dashboard/TransferController.ts +++ b/app/Controllers/Http/Dashboard/TransferController.ts | |||
@@ -68,12 +68,16 @@ export default class TransferController { | |||
68 | userId: auth.user?.id, | 68 | userId: auth.user?.id, |
69 | serviceId, | 69 | serviceId, |
70 | name: service.name, | 70 | name: service.name, |
71 | recipeId: service.recipe_id, | 71 | recipeId: service.recipe_id || service.recipeId, |
72 | settings: JSON.stringify(service.settings), | 72 | settings: |
73 | typeof service.settings === 'string' | ||
74 | ? service.settings | ||
75 | : JSON.stringify(service.settings), | ||
73 | }); | 76 | }); |
74 | 77 | ||
75 | // @ts-expect-error Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}' | 78 | // @ts-expect-error Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{}' |
76 | serviceIdTranslation[service.service_id] = serviceId; | 79 | serviceIdTranslation[service.service_id || service.serviceId] = |
80 | serviceId; | ||
77 | } | 81 | } |
78 | } catch (error) { | 82 | } catch (error) { |
79 | // eslint-disable-next-line no-console | 83 | // eslint-disable-next-line no-console |
@@ -109,7 +113,10 @@ export default class TransferController { | |||
109 | name: workspace.name, | 113 | name: workspace.name, |
110 | order: workspace.order, | 114 | order: workspace.order, |
111 | services: JSON.stringify(services), | 115 | services: JSON.stringify(services), |
112 | data: JSON.stringify(workspace.data), | 116 | data: |
117 | typeof workspace.data === 'string' | ||
118 | ? workspace.data | ||
119 | : JSON.stringify(workspace.data), | ||
113 | }); | 120 | }); |
114 | } | 121 | } |
115 | } catch (error) { | 122 | } catch (error) { |