Skip to content

Commit ecd86b1

Browse files
committed
feat: defaultFile balanceFalse returned as response if organization balance false below 0
1 parent 2f79c40 commit ecd86b1

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/index.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class CoCreateFileSystem {
4242
return file.object[0].src
4343
}
4444

45-
let default403, default404, hostNotFound, signup
45+
let default403, default404, hostNotFound, signup, balanceFalse
4646
defaultFiles('/403.html').then((file) => {
4747
default403 = file
4848
})
@@ -52,6 +52,9 @@ class CoCreateFileSystem {
5252
defaultFiles('/hostNotFound.html').then((file) => {
5353
hostNotFound = file
5454
})
55+
defaultFiles('/balanceFalse').then((file) => {
56+
balanceFalse = file
57+
})
5558
defaultFiles('/superadmin/signup.html').then((file) => {
5659
signup = file
5760
})
@@ -76,12 +79,7 @@ class CoCreateFileSystem {
7679

7780
if (!org || !org.object || !org.object[0]) {
7881
hostNotFound = hostNotFound || 'An organization could not be found using the host: ' + hostname + ' in platformDB: ' + process.env.organization_id
79-
res.writeHead(404, { 'Content-Type': 'text/html' });
80-
if (org.storage === false && org.error)
81-
res.setHeader('storage', 'false')
82-
else
83-
res.setHeader('storage', 'true')
84-
82+
res.writeHead(404, { 'Content-Type': 'text/html', 'storage': organization.storage });
8583
return res.end(hostNotFound);
8684
} else {
8785
organization = { _id: org.object[0]._id, storage: !!org.object[0].storage }
@@ -90,7 +88,16 @@ class CoCreateFileSystem {
9088
}
9189

9290
let organization_id = organization._id
91+
92+
let active = crud.wsManager.organizations.get(organization_id)
93+
if (active === false) {
94+
balanceFalse = balanceFalse || 'This organizations account balance has fallen bellow 0: '
95+
res.writeHead(404, { 'Content-Type': 'text/html', 'Account-Balance': 'false', 'storage': organization.storage });
96+
return res.end(balanceFalse);
97+
}
98+
9399
res.setHeader('organization', organization_id)
100+
res.setHeader('storage', organization.storage);
94101
res.setHeader('Access-Control-Allow-Origin', '*');
95102
res.setHeader('Access-Control-Allow-Methods', '');
96103
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization');
@@ -125,10 +132,6 @@ class CoCreateFileSystem {
125132
data.organization_id = process.env.organization_id
126133

127134
let file = await crud.send(data);
128-
if (file.storage === false && file.error)
129-
res.setHeader('storage', 'false')
130-
else
131-
res.setHeader('storage', 'true')
132135

133136
const fileContent = req.headers['File-Content']
134137
if (fileContent && !pathname.startsWith('/superadmin')) {

0 commit comments

Comments
 (0)