@@ -27,13 +27,28 @@ class CoCreateFileSystem {
27
27
28
28
async send ( req , res , crud , organization , valideUrl ) {
29
29
try {
30
+ const hostname = valideUrl . hostname ;
31
+
32
+ let data = {
33
+ method : 'object.read' ,
34
+ host : hostname ,
35
+ array : 'files' ,
36
+ $filter : {
37
+ query : {
38
+ host : { $in : [ hostname , '*' ] } ,
39
+ $or : [ ]
40
+ } ,
41
+ limit : 1
42
+ }
43
+ }
44
+
30
45
if ( ! organization || organization . error ) {
31
46
let hostNotFound = await getDefaultFile ( '/hostNotFound.html' )
32
47
return sendResponse ( hostNotFound . object [ 0 ] . src , 404 , { 'Content-Type' : 'text/html' } )
33
48
}
34
49
35
50
const organization_id = organization . _id
36
- const hostname = valideUrl . hostname ;
51
+ data . organization_id = organization_id
37
52
38
53
res . setHeader ( 'organization' , organization_id )
39
54
res . setHeader ( 'storage' , ! ! organization . storage ) ;
@@ -74,19 +89,20 @@ class CoCreateFileSystem {
74
89
pathname += "/index.html" ;
75
90
}
76
91
77
- let data = {
78
- method : 'object.read' ,
79
- host : hostname ,
80
- array : 'files' ,
81
- $filter : {
82
- query : {
83
- host : { $in : [ hostname , '*' ] } ,
84
- $or : [ { pathname } , { pathname : wildcard } ]
85
- } ,
86
- limit : 1
87
- } ,
88
- organization_id
89
- }
92
+ // let data = {
93
+ // method: 'object.read',
94
+ // host: hostname,
95
+ // array: 'files',
96
+ // $filter: {
97
+ // query: {
98
+ // host: { $in: [hostname, '*'] },
99
+ // $or: [{ pathname }, { pathname: wildcard }]
100
+ // },
101
+ // limit: 1
102
+ // },
103
+ // organization_id
104
+ // }
105
+ data . $filter . query . $or = [ { pathname } , { pathname : wildcard } ]
90
106
91
107
let file
92
108
if ( pathname . startsWith ( '/dist' ) || pathname . startsWith ( '/admin' ) || [ '/403.html' , '/404.html' , '/offline.html' , '/manifest.webmanifest' , '/service-worker.js' ] . includes ( pathname ) )
@@ -173,7 +189,7 @@ class CoCreateFileSystem {
173
189
}
174
190
175
191
async function getDefaultFile ( fileName ) {
176
- data . $filter . query . $or [ 0 ] . pathname = fileName
192
+ data . $filter . query . $or [ 0 ] = { pathname : fileName }
177
193
let defaultFile
178
194
if ( fileName !== '/hostNotFound.html' )
179
195
defaultFile = await crud . send ( data ) ;
0 commit comments