for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
import time
from django.core.exceptions import ValidationError
from django.conf import settings
class AntiSpam(object):
def __init__(self):
self.spammed = 0
self.info = {}
def check_spam(self, json_message):
message_length = len(json_message)
info_key = int(round(time.time() * 100))
self.info[info_key] = message_length
if message_length > settings.MAX_MESSAGE_SIZE:
self.spammed += 1
raise ValidationError("Message can't exceed %d symbols" % settings.MAX_MESSAGE_SIZE)
self.check_timed_spam()
def check_timed_spam(self):
# TODO implement me
pass
# raise ValidationError("You're chatting too much, calm down a bit!")