mirror of
https://github.com/NovaOSS/nova-api.git
synced 2024-11-25 14:13: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:
|
||||
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
|
||||
enterprise_keys = os.environ.get('ENTERPRISE_KEYS')
|
||||
if path.startswith('/enterprise/v1') and user.get('api_key') not in enterprise_keys.split():
|
||||
return await errors.error(403, 'Enterprise API is not available.', 'Contact the staff for an upgrade.')
|
||||
is_enterprise_key = 'enterprise' in user.get('role', 'default')
|
||||
|
||||
if path.startswith('/enterprise/v1') and not is_enterprise_key:
|
||||
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:
|
||||
return fastapi.responses.JSONResponse({'credits': user['credits']})
|
||||
|
@ -87,6 +87,9 @@ async def handle(incoming_request: fastapi.Request):
|
|||
|
||||
role = user.get('role', 'default')
|
||||
|
||||
if 'enterprise' in role:
|
||||
role_cost_multiplier = 0.1
|
||||
else:
|
||||
try:
|
||||
role_cost_multiplier = config['roles'][role]['bonus']
|
||||
except KeyError:
|
||||
|
|
Loading…
Reference in a new issue