summaryrefslogtreecommitdiff
path: root/src/services/comment_creation_callbacks.py
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2024-02-05 12:53:22 -0600
committerHombreLaser <sebastian-440@live.com>2024-02-05 12:53:22 -0600
commit3fa4434d417c4bc85916ed79cc7bbb324b2768ac (patch)
treee2c1586b94f5ac877ad0a260cd95876e99be59da /src/services/comment_creation_callbacks.py
parentbc01c595dc4f78bcbeb81577f4947b42bf8f9d61 (diff)
Add blacklist matching
Diffstat (limited to 'src/services/comment_creation_callbacks.py')
-rw-r--r--src/services/comment_creation_callbacks.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/services/comment_creation_callbacks.py b/src/services/comment_creation_callbacks.py
new file mode 100644
index 0000000..5f5d024
--- /dev/null
+++ b/src/services/comment_creation_callbacks.py
@@ -0,0 +1,27 @@
+import src.lib as lib
+from config import user_config
+from src.services.callback import Callback
+
+
+class CommentCreationCallbacks(Callback):
+ """
+ Check config for blacklists, moderation behavior and
+ notification delivery.
+ """
+ def __init__(self, comment):
+ self._comment = comment
+
+ def run_callbacks(self):
+ self._moderate()
+ self._deliver_notification()
+
+ return self._comment
+
+ def _moderate(self):
+ if user_config['Env']['moderation'] == 'strict':
+ self._comment.approved = False
+ return
+
+ if lib.contains_forbidden_term(self._comment.content):
+ if user_config['Env']['blacklist_match_action'] == 'reject':
+ self._comment.approved = False