@@ -39,20 +39,18 @@ class CoCreateFileSystem {
39
39
let org = await crud . send ( {
40
40
method : 'read.object' ,
41
41
array : 'organizations' ,
42
- object : {
43
- $filter : {
44
- query : [
45
- { key : "host" , value : [ hostname ] , operator : "$in" }
46
- ]
47
- }
42
+ $filter : {
43
+ query : [
44
+ { key : "host" , value : [ hostname ] , operator : "$in" }
45
+ ]
48
46
} ,
49
47
organization_id : process . env . organization_id
50
48
} )
51
49
52
50
if ( ! org || ! org . object || ! org . object [ 0 ] ) {
53
51
if ( ! hostNotFound )
54
52
hostNotFound = await getDefaultFile ( '/hostNotFound.html' )
55
- return sendResponse ( hostNotFound . src , 404 , { 'Content-Type' : 'text/html' , 'storage' : organization . storage } )
53
+ return sendResponse ( hostNotFound . object [ 0 ] . src , 404 , { 'Content-Type' : 'text/html' , 'storage' : organization . storage } )
56
54
} else {
57
55
organization = { _id : org . object [ 0 ] . _id , storage : ! ! org . object [ 0 ] . storage }
58
56
organizations . set ( hostname , organization )
@@ -84,7 +82,7 @@ class CoCreateFileSystem {
84
82
let active = crud . wsManager . organizations . get ( organization_id )
85
83
if ( active === false ) {
86
84
let balanceFalse = await getDefaultFile ( '/balanceFalse.html' )
87
- return sendResponse ( balanceFalse . src , 403 , { 'Content-Type' : 'text/html' , 'Account-Balance' : 'false' , 'storage' : organization . storage } )
85
+ return sendResponse ( balanceFalse . object [ 0 ] . src , 403 , { 'Content-Type' : 'text/html' , 'Account-Balance' : 'false' , 'storage' : organization . storage } )
88
86
}
89
87
90
88
const fileContent = req . headers [ 'File-Content' ]
@@ -101,14 +99,12 @@ class CoCreateFileSystem {
101
99
let data = {
102
100
method : 'read.object' ,
103
101
array : 'files' ,
104
- object : {
105
- $filter : {
106
- query : [
107
- { key : "host" , value : [ hostname , '*' ] , operator : "$in" } ,
108
- { key : "path" , value : pathname , operator : "$eq" }
109
- ] ,
110
- limit : 1
111
- }
102
+ $filter : {
103
+ query : [
104
+ { key : "host" , value : [ hostname , '*' ] , operator : "$in" } ,
105
+ { key : "path" , value : pathname , operator : "$eq" }
106
+ ] ,
107
+ limit : 1
112
108
} ,
113
109
organization_id
114
110
}
@@ -122,13 +118,13 @@ class CoCreateFileSystem {
122
118
123
119
if ( ! file || ! file . object || ! file . object [ 0 ] ) {
124
120
let pageNotFound = await getDefaultFile ( '/404.html' )
125
- return sendResponse ( pageNotFound . src , 404 , { 'Content-Type' : 'text/html' } )
121
+ return sendResponse ( pageNotFound . object [ 0 ] . src , 404 , { 'Content-Type' : 'text/html' } )
126
122
}
127
123
128
124
file = file . object [ 0 ]
129
125
if ( ! file [ 'public' ] || file [ 'public' ] === "false" ) {
130
126
let pageForbidden = await getDefaultFile ( '/403.html' )
131
- return sendResponse ( pageForbidden . src , 403 , { 'Content-Type' : 'text/html' } )
127
+ return sendResponse ( pageForbidden . object [ 0 ] . src , 403 , { 'Content-Type' : 'text/html' } )
132
128
}
133
129
134
130
let src ;
@@ -148,7 +144,7 @@ class CoCreateFileSystem {
148
144
149
145
if ( ! src ) {
150
146
let pageNotFound = await getDefaultFile ( '/404.html' )
151
- return sendResponse ( pageNotFound . src , 404 , { 'Content-Type' : 'text/html' } )
147
+ return sendResponse ( pageNotFound . object [ 0 ] . src , 404 , { 'Content-Type' : 'text/html' } )
152
148
}
153
149
154
150
let contentType = file [ 'content-type' ] || 'text/html' ;
@@ -180,15 +176,15 @@ class CoCreateFileSystem {
180
176
}
181
177
182
178
async function getDefaultFile ( fileName ) {
183
- data . object . $filter . query [ 1 ] . value = fileName
179
+ data . $filter . query [ 1 ] . value = fileName
184
180
let defaultFile
185
181
if ( fileName !== '/hostNotFound.html' )
186
182
defaultFile = await crud . send ( data ) ;
187
183
188
184
if ( defaultFile && defaultFile . object && defaultFile . object [ 0 ] && defaultFile . object [ 0 ] . src ) {
189
- return defaultFile . object [ 0 ]
185
+ return defaultFile
190
186
} else {
191
- data . object . $filter . query [ 0 ] . value = [ '*' ]
187
+ data . $filter . query [ 0 ] . value = [ '*' ]
192
188
data . organization_id = process . env . organization_id
193
189
194
190
defaultFile = await crud . send ( data )
@@ -215,20 +211,20 @@ class CoCreateFileSystem {
215
211
organization_id
216
212
} )
217
213
218
- return defaultFile . object [ 0 ]
214
+ return defaultFile
219
215
} else {
220
216
switch ( fileName ) {
221
217
case '/403.html' :
222
- defaultFile = { src : `${ pathname } access not allowed for ${ organization_id } ` } ;
218
+ defaultFile . object = [ { src : `${ pathname } access not allowed for ${ organization_id } ` } ]
223
219
break ;
224
220
case '/404.html' :
225
- defaultFile = { src : `${ pathname } could not be found for ${ organization_id } ` } ;
221
+ defaultFile . object = [ { src : `${ pathname } could not be found for ${ organization_id } ` } ] ;
226
222
break ;
227
223
case '/balanceFalse.html' :
228
- defaultFile = { src : 'This organizations account balance has fallen bellow 0: ' } ;
224
+ defaultFile . object = [ { src : 'This organizations account balance has fallen bellow 0: ' } ] ;
229
225
break ;
230
226
case '/hostNotFound.html' :
231
- defaultFile = { src : 'An organization could not be found using the host: ' + hostname + ' in platformDB: ' + process . env . organization_id } ;
227
+ defaultFile . object = [ { src : 'An organization could not be found using the host: ' + hostname + ' in platformDB: ' + process . env . organization_id } ] ;
232
228
break ;
233
229
}
234
230
return defaultFile
0 commit comments