Taking spam detection hueristics out of open source because spamming fuckers are reading the source to figure out how to game the system. Good thing I did this before re-tooling the hueristics to be smarter. Now they'll have to work that much harder. Fuckers.

This commit is contained in:
Samuel Clay 2014-09-17 14:01:19 -07:00
parent 2c41b3ae70
commit 0e42dd5467
2 changed files with 12 additions and 38 deletions

1
.gitignore vendored
View file

@ -34,6 +34,7 @@ config/settings
config/secrets config/secrets
templates/maintenance_on.html templates/maintenance_on.html
vendor/mms-agent/settings.py vendor/mms-agent/settings.py
apps/social/spam.py
# ---------------------- # ----------------------
# Android # Android

View file

@ -15,7 +15,6 @@ from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.sites.models import Site from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.db.models.aggregates import Sum
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
from django.core.mail import EmailMultiAlternatives from django.core.mail import EmailMultiAlternatives
@ -37,6 +36,12 @@ from utils.scrubber import SelectiveScriptScrubber
from utils import s3_utils from utils import s3_utils
from StringIO import StringIO from StringIO import StringIO
try:
from apps.social.spam import detect_spammers
except ImportError:
logging.debug(" ---> ~SN~FRCouldn't find ~SBspam.py~SN.")
pass
RECOMMENDATIONS_LIMIT = 5 RECOMMENDATIONS_LIMIT = 5
IGNORE_IMAGE_SOURCES = [ IGNORE_IMAGE_SOURCES = [
"http://feeds.feedburner.com" "http://feeds.feedburner.com"
@ -1500,43 +1505,11 @@ class MSharedStory(mongo.Document):
@classmethod @classmethod
def count_potential_spammers(cls, days=1, destroy=False): def count_potential_spammers(cls, days=1, destroy=False):
day_ago = datetime.datetime.now()-datetime.timedelta(days=days) try:
stories = cls.objects.filter(shared_date__gte=day_ago) guaranteed_spammers = detect_spammers(days=days, destroy=destroy)
shared = [{'u': s.user_id, 'f': s.story_feed_id} for s in stories] except NameError:
ddusers = defaultdict(lambda: defaultdict(int)) logging.debug(" ---> ~FR~SNMissing ~SBspam.py~SN")
for story in shared: guaranteed_spammers = []
ddusers[story['u']][story['f']] += 1
users = {}
for user_id, feeds in ddusers.items():
users[user_id] = dict(feeds)
guaranteed_spammers = []
for user_id in ddusers.keys():
u = User.objects.get(pk=user_id)
if u.profile.is_premium: continue
feed_opens = UserSubscription.objects.filter(user=u).aggregate(sum=Sum('feed_opens'))['sum']
read_story_count = RUserStory.read_story_count(user_id)
feed_count = UserSubscription.objects.filter(user=u).count()
share_count = MSharedStory.objects.filter(user_id=user_id).count()
print " ---> %s (%s): feed_opens:%s feeds:%s read:%s shared:%s" % (
u.username, u.pk,
feed_opens,
feed_count,
read_story_count,
share_count,
)
if not feed_opens: guaranteed_spammers.append(user_id)
if (feed_count <= 5 and
feed_opens <= 10 and
read_story_count < share_count*2): guaranteed_spammers.append(user_id)
print " ---> Guaranteed spammers: %s" % guaranteed_spammers
if destroy and guaranteed_spammers:
for spammer_id in guaranteed_spammers:
user = User.objects.get(pk=spammer_id)
user.profile.delete_user(confirm=True, fast=True)
return guaranteed_spammers return guaranteed_spammers