mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 23:39:11 -05:00
spam-related update
This commit is contained in:
@@ -126,11 +126,8 @@ class ApiController(RedditController):
|
||||
form.has_errors("subject", errors.NO_SUBJECT) or
|
||||
form.has_errors("text", errors.NO_TEXT, errors.TOO_LONG) or
|
||||
form.has_errors("captcha", errors.BAD_CAPTCHA)):
|
||||
spam = (c.user._spam or
|
||||
errors.BANNED_IP in c.errors or
|
||||
errors.BANNED_DOMAIN in c.errors)
|
||||
|
||||
m, inbox_rel = Message._new(c.user, to, subject, body, ip, spam)
|
||||
m, inbox_rel = Message._new(c.user, to, subject, body, ip)
|
||||
form.set_html(".status", _("your message has been delivered"))
|
||||
form.set_inputs(to = "", subject = "", text = "", captcha="")
|
||||
|
||||
@@ -202,14 +199,9 @@ class ApiController(RedditController):
|
||||
if form.has_error() or not title:
|
||||
return
|
||||
|
||||
# check whether this is spam:
|
||||
spam = (c.user._spam or
|
||||
errors.BANNED_IP in c.errors or
|
||||
errors.BANNED_DOMAIN in c.errors)
|
||||
|
||||
# well, nothing left to do but submit it
|
||||
l = Link._submit(request.post.title, url if kind == 'link' else 'self',
|
||||
c.user, sr, ip, spam)
|
||||
c.user, sr, ip)
|
||||
|
||||
if kind == 'self':
|
||||
l.url = l.make_permalink_slow()
|
||||
@@ -219,7 +211,7 @@ class ApiController(RedditController):
|
||||
l._commit()
|
||||
l.set_url_cache()
|
||||
|
||||
v = Vote.vote(c.user, l, True, ip, spam)
|
||||
v = Vote.vote(c.user, l, True, ip)
|
||||
if save:
|
||||
r = l._save(c.user)
|
||||
if g.write_query_queue:
|
||||
@@ -455,8 +447,7 @@ class ApiController(RedditController):
|
||||
title = container.title)
|
||||
msg = msg % d
|
||||
subj = subj % d
|
||||
Message._new(c.user, friend, subj, msg, ip,
|
||||
c.user._spam)
|
||||
Message._new(c.user, friend, subj, msg, ip)
|
||||
|
||||
|
||||
@validatedForm(VUser('curpass', default = ''),
|
||||
@@ -613,7 +604,6 @@ class ApiController(RedditController):
|
||||
errors.RATELIMIT) and
|
||||
not commentform.has_errors("parent",
|
||||
errors.DELETED_COMMENT)):
|
||||
spam = (c.user._spam or errors.BANNED_IP in c.errors)
|
||||
|
||||
if is_message:
|
||||
to = Account._byID(parent.author_id)
|
||||
@@ -622,11 +612,11 @@ class ApiController(RedditController):
|
||||
if not subject.startswith(re):
|
||||
subject = re + subject
|
||||
item, inbox_rel = Message._new(c.user, to, subject,
|
||||
comment, ip, spam)
|
||||
comment, ip)
|
||||
item.parent_id = parent._id
|
||||
else:
|
||||
item, inbox_rel = Comment._new(c.user, link, parent_comment,
|
||||
comment, ip, spam)
|
||||
comment, ip)
|
||||
Vote.vote(c.user, item, True, ip)
|
||||
# flag search indexer that something has changed
|
||||
tc.changed(item)
|
||||
@@ -733,9 +723,6 @@ class ApiController(RedditController):
|
||||
def POST_vote(self, dir, thing, ip, vote_type):
|
||||
ip = request.ip
|
||||
user = c.user
|
||||
spam = (c.user._spam or
|
||||
errors.BANNED_IP in c.errors or
|
||||
errors.CHEATER in c.errors)
|
||||
# TODO: temporary hack until we migrate the rest of the vote data
|
||||
if thing and thing._date < datetime(2009, 4, 17, 0, 0, 0, 0, g.tz):
|
||||
g.log.debug("POST_vote: ignoring old vote on %s" % thing._fullname)
|
||||
@@ -744,7 +731,7 @@ class ApiController(RedditController):
|
||||
else False if dir < 0
|
||||
else None)
|
||||
organic = vote_type == 'organic'
|
||||
v = Vote.vote(user, thing, dir, ip, spam, organic)
|
||||
v = Vote.vote(user, thing, dir, ip, organic)
|
||||
|
||||
#update relevant caches
|
||||
if isinstance(thing, Link):
|
||||
|
||||
@@ -47,7 +47,7 @@ def is_banned_domain(dom):
|
||||
return False
|
||||
|
||||
def valid_thing(v, karma):
|
||||
return True
|
||||
return not v._thing1._spam
|
||||
|
||||
def valid_user(v, sr, karma):
|
||||
return True
|
||||
|
||||
@@ -32,7 +32,7 @@ from mako.filters import url_escape
|
||||
from r2.lib.strings import strings, Score
|
||||
|
||||
from pylons import c, g, request
|
||||
from pylons.i18n import ungettext
|
||||
from pylons.i18n import ungettext, _
|
||||
|
||||
import random
|
||||
|
||||
@@ -116,10 +116,10 @@ class Link(Thing, Printable):
|
||||
return submit_url
|
||||
|
||||
@classmethod
|
||||
def _submit(cls, title, url, author, sr, ip, spam = False):
|
||||
def _submit(cls, title, url, author, sr, ip):
|
||||
l = cls(title = title,
|
||||
url = url,
|
||||
_spam = spam,
|
||||
_spam = author._spam,
|
||||
author_id = author._id,
|
||||
sr_id = sr._id,
|
||||
lang = sr.lang,
|
||||
@@ -439,14 +439,14 @@ class Comment(Thing, Printable):
|
||||
link._incr('num_comments', -1)
|
||||
|
||||
@classmethod
|
||||
def _new(cls, author, link, parent, body, ip, spam = False):
|
||||
def _new(cls, author, link, parent, body, ip):
|
||||
c = Comment(body = body,
|
||||
link_id = link._id,
|
||||
sr_id = link.sr_id,
|
||||
author_id = author._id,
|
||||
ip = ip)
|
||||
|
||||
c._spam = spam
|
||||
c._spam = author._spam
|
||||
|
||||
#these props aren't relations
|
||||
if parent:
|
||||
@@ -645,12 +645,12 @@ class Message(Thing, Printable):
|
||||
cache_ignore = set(["to"]).union(Printable.cache_ignore)
|
||||
|
||||
@classmethod
|
||||
def _new(cls, author, to, subject, body, ip, spam = False):
|
||||
def _new(cls, author, to, subject, body, ip):
|
||||
m = Message(subject = subject,
|
||||
body = body,
|
||||
author_id = author._id,
|
||||
ip = ip)
|
||||
m._spam = spam
|
||||
m._spam = author._spam
|
||||
m.to_id = to._id
|
||||
m._commit()
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class Vote(MultiRelation('vote',
|
||||
|
||||
|
||||
@classmethod
|
||||
def vote(cls, sub, obj, dir, ip, spam = False, organic = False):
|
||||
def vote(cls, sub, obj, dir, ip, organic = False):
|
||||
from admintools import valid_user, valid_thing, update_score
|
||||
from r2.lib.count import incr_counts
|
||||
|
||||
@@ -80,8 +80,7 @@ class Vote(MultiRelation('vote',
|
||||
#these still need to be recalculated
|
||||
old_valid_thing = v.valid_thing
|
||||
v.valid_thing = (valid_thing(v, karma)
|
||||
and v.valid_thing
|
||||
and not spam)
|
||||
and v.valid_thing)
|
||||
v.valid_user = (v.valid_user
|
||||
and v.valid_thing
|
||||
and valid_user(v, sr, karma))
|
||||
@@ -92,8 +91,7 @@ class Vote(MultiRelation('vote',
|
||||
v = rel(sub, obj, str(amount))
|
||||
v.author_id = obj.author_id
|
||||
v.ip = ip
|
||||
old_valid_thing = v.valid_thing = (valid_thing(v, karma) and
|
||||
not spam)
|
||||
old_valid_thing = v.valid_thing = (valid_thing(v, karma))
|
||||
v.valid_user = (v.valid_thing and valid_user(v, sr, karma)
|
||||
and not is_self_link)
|
||||
if organic:
|
||||
|
||||
@@ -1229,6 +1229,25 @@ textarea.gray { color: gray; }
|
||||
.details td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.vote-note {
|
||||
max-width: 200px;
|
||||
}
|
||||
.vote-a-notes {
|
||||
color: red;
|
||||
}
|
||||
.vote-up {
|
||||
color: orangered;
|
||||
}
|
||||
.vote-down {
|
||||
color: #336699;
|
||||
}
|
||||
.vote-invalid {
|
||||
color: #888888 !important;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
|
||||
.bottommenu { color: gray; font-size: smaller; clear: both}
|
||||
.bottommenu a { color: gray; text-decoration: underline; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user