diff options
author | 2022-01-07 12:45:44 +0100 | |
---|---|---|
committer | 2022-01-07 12:45:44 +0100 | |
commit | 1101eb3801fb265221baee91428ba1c9a19f6150 (patch) | |
tree | 2d95c799da68f43c951abf82b2cbe499f63e9c61 /src/internal-server/app | |
parent | Use window.fetch in getRecipePackage, removes electron-fetch (diff) | |
download | ferdium-app-1101eb3801fb265221baee91428ba1c9a19f6150.tar.gz ferdium-app-1101eb3801fb265221baee91428ba1c9a19f6150.tar.zst ferdium-app-1101eb3801fb265221baee91428ba1c9a19f6150.zip |
Eventually get remote recipes updates in internal server
Diffstat (limited to 'src/internal-server/app')
-rw-r--r-- | src/internal-server/app/Controllers/Http/RecipeController.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index daa9356f6..37a62e2fa 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js | |||
@@ -85,10 +85,17 @@ class RecipeController { | |||
85 | return response.send(results); | 85 | return response.send(results); |
86 | } | 86 | } |
87 | 87 | ||
88 | // Return an empty array | 88 | async update({ request, response }) { |
89 | update({ | 89 | // eslint-disable-next-line eqeqeq |
90 | response, | 90 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { |
91 | }) { | 91 | const body = request.all(); |
92 | const remoteUpdates = await fetch(`${RECIPES_URL}/update`, { | ||
93 | method: 'POST', | ||
94 | body: JSON.stringify(body), | ||
95 | headers: {'Content-Type': 'application/json'} | ||
96 | }); | ||
97 | return response.send(await remoteUpdates.json()); | ||
98 | } | ||
92 | return response.send([]); | 99 | return response.send([]); |
93 | } | 100 | } |
94 | 101 | ||
@@ -116,19 +123,18 @@ class RecipeController { | |||
116 | 123 | ||
117 | const service = params.recipe; | 124 | const service = params.recipe; |
118 | 125 | ||
126 | // eslint-disable-next-line eqeqeq | ||
127 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { | ||
128 | return response.redirect(`${RECIPES_URL}/download/${service}`); | ||
129 | } | ||
119 | // Check for invalid characters | 130 | // Check for invalid characters |
120 | if (/\.+/.test(service) || /\/+/.test(service)) { | 131 | if (/\.+/.test(service) || /\/+/.test(service)) { |
121 | return response.send('Invalid recipe name'); | 132 | return response.send('Invalid recipe name'); |
122 | } | 133 | } |
123 | |||
124 | // Check if recipe exists in recipes folder | 134 | // Check if recipe exists in recipes folder |
125 | if (await Drive.exists(`${service}.tar.gz`)) { | 135 | if (await Drive.exists(`${service}.tar.gz`)) { |
126 | return response.send(await Drive.get(`${service}.tar.gz`)); | 136 | return response.send(await Drive.get(`${service}.tar.gz`)); |
127 | } | 137 | } |
128 | // eslint-disable-next-line eqeqeq | ||
129 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { | ||
130 | return response.redirect(`${RECIPES_URL}/download/${service}`); | ||
131 | } | ||
132 | return response.status(400).send({ | 138 | return response.status(400).send({ |
133 | message: 'Recipe not found', | 139 | message: 'Recipe not found', |
134 | code: 'recipe-not-found', | 140 | code: 'recipe-not-found', |