diff options
author | vantezzen <hello@vantezzen.io> | 2019-10-17 21:45:24 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2019-10-17 21:45:24 +0200 |
commit | ad97ba68b004b746d1e78cedc87a2dab9b93d3c5 (patch) | |
tree | d6a57868a1bb4aa23c13fac0f2d47d7fc8d9c250 | |
parent | Add announcements (diff) | |
download | ferdium-server-ad97ba68b004b746d1e78cedc87a2dab9b93d3c5.tar.gz ferdium-server-ad97ba68b004b746d1e78cedc87a2dab9b93d3c5.tar.zst ferdium-server-ad97ba68b004b746d1e78cedc87a2dab9b93d3c5.zip |
Fix compatability to Postgresql databases
-rw-r--r-- | app/Controllers/Http/RecipeController.js | 6 | ||||
-rw-r--r-- | app/Controllers/Http/ServiceController.js | 8 | ||||
-rw-r--r-- | app/Controllers/Http/WorkspaceController.js | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index 880f0c3..6c8aa21 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js | |||
@@ -35,7 +35,7 @@ class RecipeController { | |||
35 | const customRecipes = customRecipesArray.map((recipe) => ({ | 35 | const customRecipes = customRecipesArray.map((recipe) => ({ |
36 | id: recipe.recipeId, | 36 | id: recipe.recipeId, |
37 | name: recipe.name, | 37 | name: recipe.name, |
38 | ...JSON.parse(recipe.data), | 38 | ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, |
39 | })); | 39 | })); |
40 | 40 | ||
41 | const recipes = [ | 41 | const recipes = [ |
@@ -144,7 +144,7 @@ class RecipeController { | |||
144 | results = dbResults.map((recipe) => ({ | 144 | results = dbResults.map((recipe) => ({ |
145 | id: recipe.recipeId, | 145 | id: recipe.recipeId, |
146 | name: recipe.name, | 146 | name: recipe.name, |
147 | ...JSON.parse(recipe.data), | 147 | ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, |
148 | })); | 148 | })); |
149 | } else { | 149 | } else { |
150 | let remoteResults = []; | 150 | let remoteResults = []; |
@@ -155,7 +155,7 @@ class RecipeController { | |||
155 | const localResults = localResultsArray.map((recipe) => ({ | 155 | const localResults = localResultsArray.map((recipe) => ({ |
156 | id: recipe.recipeId, | 156 | id: recipe.recipeId, |
157 | name: recipe.name, | 157 | name: recipe.name, |
158 | ...JSON.parse(recipe.data), | 158 | ...typeof recipe.data === "string" ? JSON.parse(recipe.data) : recipe.data, |
159 | })); | 159 | })); |
160 | 160 | ||
161 | results = [ | 161 | results = [ |
diff --git a/app/Controllers/Http/ServiceController.js b/app/Controllers/Http/ServiceController.js index 1dfec49..7162268 100644 --- a/app/Controllers/Http/ServiceController.js +++ b/app/Controllers/Http/ServiceController.js | |||
@@ -93,7 +93,7 @@ class ServiceController { | |||
93 | spellcheckerLanguage: '', | 93 | spellcheckerLanguage: '', |
94 | workspaces: [], | 94 | workspaces: [], |
95 | iconUrl: null, | 95 | iconUrl: null, |
96 | ...JSON.parse(service.settings), | 96 | ...typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings, |
97 | id: service.serviceId, | 97 | id: service.serviceId, |
98 | name: service.name, | 98 | name: service.name, |
99 | recipeId: service.recipeId, | 99 | recipeId: service.recipeId, |
@@ -138,7 +138,7 @@ class ServiceController { | |||
138 | .where('userId', auth.user.id).fetch()).rows[0]; | 138 | .where('userId', auth.user.id).fetch()).rows[0]; |
139 | 139 | ||
140 | const settings = { | 140 | const settings = { |
141 | ...JSON.parse(serviceData.settings), | 141 | ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, |
142 | ...data, | 142 | ...data, |
143 | }; | 143 | }; |
144 | 144 | ||
@@ -177,7 +177,7 @@ class ServiceController { | |||
177 | .where('userId', auth.user.id).fetch()).rows[0]; | 177 | .where('userId', auth.user.id).fetch()).rows[0]; |
178 | 178 | ||
179 | const settings = { | 179 | const settings = { |
180 | ...JSON.parse(serviceData.settings), | 180 | ...typeof serviceData.settings === "string" ? JSON.parse(serviceData.settings) : serviceData.settings, |
181 | order: data[service], | 181 | order: data[service], |
182 | }; | 182 | }; |
183 | 183 | ||
@@ -205,7 +205,7 @@ class ServiceController { | |||
205 | spellcheckerLanguage: '', | 205 | spellcheckerLanguage: '', |
206 | workspaces: [], | 206 | workspaces: [], |
207 | iconUrl: null, | 207 | iconUrl: null, |
208 | ...JSON.parse(service.settings), | 208 | ...typeof service.settings === "string" ? JSON.parse(service.settings) : service.settings, |
209 | id: service.serviceId, | 209 | id: service.serviceId, |
210 | name: service.name, | 210 | name: service.name, |
211 | recipeId: service.recipeId, | 211 | recipeId: service.recipeId, |
diff --git a/app/Controllers/Http/WorkspaceController.js b/app/Controllers/Http/WorkspaceController.js index ecf79af..45ed6cc 100644 --- a/app/Controllers/Http/WorkspaceController.js +++ b/app/Controllers/Http/WorkspaceController.js | |||
@@ -168,7 +168,7 @@ class WorkspaceController { | |||
168 | id: workspace.workspaceId, | 168 | id: workspace.workspaceId, |
169 | name: workspace.name, | 169 | name: workspace.name, |
170 | order: workspace.order, | 170 | order: workspace.order, |
171 | services: JSON.parse(workspace.services), | 171 | ...typeof workspace.services === "string" ? JSON.parse(workspace.services) : workspace.services, |
172 | userId: auth.user.id, | 172 | userId: auth.user.id, |
173 | })); | 173 | })); |
174 | } | 174 | } |