mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
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:
parent
2c41b3ae70
commit
0e42dd5467
2 changed files with 12 additions and 38 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -34,6 +34,7 @@ config/settings
|
|||
config/secrets
|
||||
templates/maintenance_on.html
|
||||
vendor/mms-agent/settings.py
|
||||
apps/social/spam.py
|
||||
|
||||
# ----------------------
|
||||
# Android
|
||||
|
|
|
@ -15,7 +15,6 @@ from django.conf import settings
|
|||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.db.models.aggregates import Sum
|
||||
from django.template.loader import render_to_string
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.core.mail import EmailMultiAlternatives
|
||||
|
@ -37,6 +36,12 @@ from utils.scrubber import SelectiveScriptScrubber
|
|||
from utils import s3_utils
|
||||
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
|
||||
IGNORE_IMAGE_SOURCES = [
|
||||
"http://feeds.feedburner.com"
|
||||
|
@ -1500,43 +1505,11 @@ class MSharedStory(mongo.Document):
|
|||
|
||||
@classmethod
|
||||
def count_potential_spammers(cls, days=1, destroy=False):
|
||||
day_ago = datetime.datetime.now()-datetime.timedelta(days=days)
|
||||
stories = cls.objects.filter(shared_date__gte=day_ago)
|
||||
shared = [{'u': s.user_id, 'f': s.story_feed_id} for s in stories]
|
||||
ddusers = defaultdict(lambda: defaultdict(int))
|
||||
for story in shared:
|
||||
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)
|
||||
try:
|
||||
guaranteed_spammers = detect_spammers(days=days, destroy=destroy)
|
||||
except NameError:
|
||||
logging.debug(" ---> ~FR~SNMissing ~SBspam.py~SN")
|
||||
guaranteed_spammers = []
|
||||
|
||||
return guaranteed_spammers
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue