return res.c or 0
- async def check_spam(self, uid, email, address):
- sfs = StopForumSpam(self.backend, uid, email, address)
+ async def check_spam(self, email, address):
+ sfs = StopForumSpam(self.backend, email, address)
# Get spam score
score = await sfs.check()
class StopForumSpam(Object):
- def init(self, uid, email, address):
- self.uid, self.email, self.address = uid, email, address
+ def init(self, email, address):
+ self.email, self.address = email, address
async def send_request(self, **kwargs):
arguments = {
return confidence
- async def check_username(self):
- response = await self.send_request(username=self.uid)
-
- try:
- confidence = response["username"]["confidence"]
- except KeyError:
- confidence = 100
-
- logging.debug("Confidence for %s: %s" % (self.uid, confidence))
-
- return confidence
-
async def check_email(self):
response = await self.send_request(email=self.email)
address and username and if those are on the database, we
will send the email address as well.
"""
- confidences = [await self.check_address(), await self.check_username()]
-
- if any((c < threshold for c in confidences)):
- confidences.append(await self.check_email())
+ confidences = [await self.check_address(), await self.check_email()]
# Build a score based on the lowest confidence
return 100 - min(confidences)
last_name = self.get_argument("last_name")
# Check if this is a spam account
- is_spam = await self.backend.accounts.check_spam(uid, email,
+ is_spam = await self.backend.accounts.check_spam(email,
address=self.get_remote_ip())
if is_spam: