forked from open-webui/open-webui
refactor: restrict the scope of USER_PERMISSIONS_CHAT_DELETION
it can easily confuse people before becuase when people accidentally set `env.USER_PERMISSIONS_CHAT_DELETION` to `true/yes/Yes`, `USER_PERMISSIONS["chat"]["deletion"]` would become `False`, which is unexpectedly and hard to notice.
This commit is contained in:
parent
04e3b168a6
commit
c6e14ce327
2 changed files with 7 additions and 3 deletions
|
@ -289,8 +289,12 @@ DEFAULT_PROMPT_SUGGESTIONS = (
|
||||||
|
|
||||||
DEFAULT_USER_ROLE = os.getenv("DEFAULT_USER_ROLE", "pending")
|
DEFAULT_USER_ROLE = os.getenv("DEFAULT_USER_ROLE", "pending")
|
||||||
|
|
||||||
USER_PERMISSIONS_CHAT_DELETION = os.getenv('USER_PERMISSIONS_CHAT_DELETION', 'True') == 'True'
|
USER_PERMISSIONS_CHAT_DELETION = os.getenv('USER_PERMISSIONS_CHAT_DELETION', 'True')
|
||||||
USER_PERMISSIONS = {"chat": {"deletion": USER_PERMISSIONS_CHAT_DELETION}}
|
|
||||||
|
if USER_PERMISSIONS_CHAT_DELETION not in ('True', 'False'):
|
||||||
|
raise ValueError(ERROR_MESSAGES.INCORRECT_FORMAT(" (e.g., True/False)."))
|
||||||
|
|
||||||
|
USER_PERMISSIONS = {"chat": {"deletion": USER_PERMISSIONS_CHAT_DELETION == 'True'}}
|
||||||
|
|
||||||
|
|
||||||
MODEL_FILTER_ENABLED = os.environ.get("MODEL_FILTER_ENABLED", False)
|
MODEL_FILTER_ENABLED = os.environ.get("MODEL_FILTER_ENABLED", False)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class ERROR_MESSAGES(str, Enum):
|
||||||
|
|
||||||
PANDOC_NOT_INSTALLED = "Pandoc is not installed on the server. Please contact your administrator for assistance."
|
PANDOC_NOT_INSTALLED = "Pandoc is not installed on the server. Please contact your administrator for assistance."
|
||||||
INCORRECT_FORMAT = (
|
INCORRECT_FORMAT = (
|
||||||
lambda err="": f"Invalid format. Please use the correct format{err if err else ''}"
|
lambda err="": f"Invalid format. Please use the correct format{err}"
|
||||||
)
|
)
|
||||||
RATE_LIMIT_EXCEEDED = "API rate limit exceeded"
|
RATE_LIMIT_EXCEEDED = "API rate limit exceeded"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue