-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
100 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,21 +135,6 @@ export async function createLocations( | |
device, | ||
org, | ||
) { | ||
if (isDeniedCompany(org)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server1?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
|
||
if (isDeniedDevice(device.model)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server2?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
const batch = firestore.batch(); | ||
await Promise.reduce( | ||
locations, | ||
|
@@ -172,6 +157,21 @@ export async function createLocations( | |
} | ||
|
||
export async function create(params) { | ||
if (Array.isArray(params)) { | ||
return Promise.reduce( | ||
params, | ||
async (p, pp) => { | ||
try { | ||
await create(pp); | ||
} catch (e) { | ||
console.error('create', e); | ||
throw e; | ||
} | ||
}, | ||
0, | ||
); | ||
} | ||
|
||
const { | ||
company_token: token = 'UNKNOWN', | ||
location: list = [], | ||
|
@@ -185,6 +185,21 @@ export async function create(params) { | |
: [] | ||
); | ||
|
||
if (isDeniedCompany(token)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server1?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
|
||
if (isDeniedDevice(device.model)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server2?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
return createLocations(locations, device, token); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,14 +76,6 @@ export async function getLatestLocation(params, isAdmin) { | |
} | ||
|
||
export async function createLocation(location, deviceInfo, org) { | ||
if (isDeniedDevice(deviceInfo.model)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server2?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
|
||
const now = new Date(); | ||
const device = await findOrCreate(org, { ...deviceInfo }); | ||
|
||
|
@@ -122,14 +114,6 @@ export async function createLocations( | |
device, | ||
org, | ||
) { | ||
if (isDeniedCompany(org)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server1?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
|
||
return Promise.reduce( | ||
locations, | ||
async (p, location) => { | ||
|
@@ -151,6 +135,21 @@ export async function createLocations( | |
export async function create( | ||
params, | ||
) { | ||
if (Array.isArray(params)) { | ||
return Promise.reduce( | ||
params, | ||
async (p, pp) => { | ||
try { | ||
await create(pp); | ||
} catch (e) { | ||
console.error('create', e); | ||
throw e; | ||
} | ||
}, | ||
0, | ||
); | ||
} | ||
|
||
const { | ||
company_token: token = 'UNKNOWN', | ||
location: list = [], | ||
|
@@ -163,7 +162,20 @@ export async function create( | |
? [list] | ||
: [] | ||
); | ||
|
||
if (isDeniedCompany(token)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server1?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
if (isDeniedDevice(device.model)) { | ||
throw new AccessDeniedError( | ||
'This is a question from the CEO of Transistor Software.\n' + | ||
'Why are you spamming my demo server2?\n' + | ||
'Please email me at [email protected].', | ||
); | ||
} | ||
return createLocations(locations, device, token); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters