New secrets system and quotas (#35)
This commit is contained in:
@@ -3,6 +3,7 @@ from fastapi.responses import UJSONResponse
|
||||
from starlette.status import (
|
||||
HTTP_400_BAD_REQUEST,
|
||||
HTTP_401_UNAUTHORIZED,
|
||||
HTTP_403_FORBIDDEN,
|
||||
HTTP_404_NOT_FOUND,
|
||||
HTTP_406_NOT_ACCEPTABLE,
|
||||
HTTP_409_CONFLICT,
|
||||
@@ -10,19 +11,20 @@ from starlette.status import (
|
||||
)
|
||||
|
||||
from classes.exceptions import (
|
||||
AlbumNotFoundError,
|
||||
AccessTokenInvalidError,
|
||||
AlbumAlreadyExistsError,
|
||||
AlbumIncorrectError,
|
||||
AlbumNotFoundError,
|
||||
PhotoNotFoundError,
|
||||
PhotoSearchQueryEmptyError,
|
||||
VideoNotFoundError,
|
||||
VideoSearchQueryEmptyError,
|
||||
SearchPageInvalidError,
|
||||
SearchTokenInvalidError,
|
||||
AccessTokenInvalidError,
|
||||
UserEmailCodeInvalid,
|
||||
UserAlreadyExists,
|
||||
UserCredentialsInvalid,
|
||||
UserEmailCodeInvalid,
|
||||
UserMediaQuotaReached,
|
||||
VideoNotFoundError,
|
||||
VideoSearchQueryEmptyError,
|
||||
)
|
||||
from modules.app import app
|
||||
|
||||
@@ -155,3 +157,13 @@ async def user_credentials_invalid_exception_handler(
|
||||
status_code=HTTP_401_UNAUTHORIZED,
|
||||
content={"detail": "Invalid credentials."},
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(UserMediaQuotaReached)
|
||||
async def user_media_quota_reached_exception_handler(
|
||||
request: Request, exc: UserMediaQuotaReached
|
||||
):
|
||||
return UJSONResponse(
|
||||
status_code=HTTP_403_FORBIDDEN,
|
||||
content={"detail": "Media quota has been reached, media upload impossible."},
|
||||
)
|
||||
|
Reference in New Issue
Block a user