mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 16:23:57 +01:00
Enterprise fix
This commit is contained in:
parent
fa1200fba3
commit
45c6a14dc0
|
@ -71,10 +71,10 @@ async def handle(incoming_request: fastapi.Request):
|
||||||
if ban_reason:
|
if ban_reason:
|
||||||
return await errors.error(403, f'Your NovaAI account has been banned. Reason: \'{ban_reason}\'.', 'Contact the staff for an appeal.')
|
return await errors.error(403, f'Your NovaAI account has been banned. Reason: \'{ban_reason}\'.', 'Contact the staff for an appeal.')
|
||||||
|
|
||||||
# Checking for enterprise status
|
is_enterprise_key = 'enterprise' in user.get('role', 'default')
|
||||||
enterprise_keys = os.environ.get('ENTERPRISE_KEYS')
|
|
||||||
if path.startswith('/enterprise/v1') and user.get('api_key') not in enterprise_keys.split():
|
if path.startswith('/enterprise/v1') and not is_enterprise_key:
|
||||||
return await errors.error(403, 'Enterprise API is not available.', 'Contact the staff for an upgrade.')
|
return await errors.error(403, 'Enterprise API is not available for your API key.', 'Contact the staff for an upgrade.')
|
||||||
|
|
||||||
if 'account/credits' in path:
|
if 'account/credits' in path:
|
||||||
return fastapi.responses.JSONResponse({'credits': user['credits']})
|
return fastapi.responses.JSONResponse({'credits': user['credits']})
|
||||||
|
@ -87,6 +87,9 @@ async def handle(incoming_request: fastapi.Request):
|
||||||
|
|
||||||
role = user.get('role', 'default')
|
role = user.get('role', 'default')
|
||||||
|
|
||||||
|
if 'enterprise' in role:
|
||||||
|
role_cost_multiplier = 0.1
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
role_cost_multiplier = config['roles'][role]['bonus']
|
role_cost_multiplier = config['roles'][role]['bonus']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in a new issue