From cc5ee65a53ede93ba5b5ed9f3a164529ec565144 Mon Sep 17 00:00:00 2001 From: IgorVolochay Date: Wed, 26 Feb 2025 17:37:19 +0300 Subject: [PATCH] fix: add check text lenght in base moderation --- app/base_moderation.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/base_moderation.py b/app/base_moderation.py index 4a7e096..5623d2f 100644 --- a/app/base_moderation.py +++ b/app/base_moderation.py @@ -16,5 +16,9 @@ def has_no_dirty_words(text: str) -> bool: words = set(re.findall(r'\w+', text.lower())) return not bool(words & dirty_words_set) +def text_lenght(text: str) -> bool: + """Check max text lenght""" + return len(text) <= 150 # TODO: update in future + def moderate_text(text: str) -> bool: - return is_not_empty(text) and has_no_links(text) and has_no_dirty_words(text) + return is_not_empty(text) and has_no_links(text) and has_no_dirty_words(text) and text_lenght(text)