blob: 5f5d024588ce3ed12000bf958e4abf36dbe920bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|