def spam(self, things, auto, moderator_banned, banner, date = None, **kw): from r2.lib.db import queries things = [x for x in tup(things) if not x._spam] Report.accept(things, True) for t in things: t._spam = True ban_info = copy(getattr(t, 'ban_info', {})) ban_info.update(auto = auto, moderator_banned = moderator_banned, banned_at = date or datetime.now(g.tz), **kw) if isinstance(banner, dict): ban_info['banner'] = banner[t._fullname] else: ban_info['banner'] = banner t.ban_info = ban_info t._commit() changed(t) if not auto: self.author_spammer(things, True) self.set_last_sr_ban(things) queries.ban(things)
def spam(self, things, auto=True, moderator_banned=False, banner=None, date = None, **kw): from r2.lib.db import queries all_things = tup(things) new_things = [x for x in all_things if not x._spam] # No need to accept reports on things with _spam=True, # since nobody can report them in the first place. Report.accept(new_things, True) for t in all_things: if getattr(t, "promoted", None) is not None: g.log.debug("Refusing to mark promotion %r as spam" % t) continue t._spam = True ban_info = copy(getattr(t, 'ban_info', {})) ban_info.update(auto = auto, moderator_banned = moderator_banned, banned_at = date or datetime.now(g.tz), **kw) if isinstance(banner, dict): ban_info['banner'] = banner[t._fullname] else: ban_info['banner'] = banner t.ban_info = ban_info t._commit() if not auto: self.author_spammer(new_things, True) self.set_last_sr_ban(new_things) queries.ban(new_things)
def spam(self, things, auto=True, moderator_banned=False, banner=None, date=None, train_spam=True, **kw): from r2.lib.db import queries all_things = tup(things) new_things = [x for x in all_things if not x._spam] Report.accept(all_things, True) for t in all_things: if getattr(t, "promoted", None) is not None: g.log.debug("Refusing to mark promotion %r as spam" % t) continue if not t._spam and train_spam: note = 'spam' elif not t._spam and not train_spam: note = 'remove not spam' elif t._spam and not train_spam: note = 'confirm spam' elif t._spam and train_spam: note = 'reinforce spam' t._spam = True if moderator_banned: t.verdict = 'mod-removed' elif not auto: t.verdict = 'admin-removed' ban_info = copy(getattr(t, 'ban_info', {})) if isinstance(banner, dict): ban_info['banner'] = banner[t._fullname] else: ban_info['banner'] = banner ban_info.update(auto=auto, moderator_banned=moderator_banned, banned_at=date or datetime.now(g.tz), **kw) ban_info['note'] = note t.ban_info = ban_info t._commit() if auto: amqp.add_item("auto_removed", t._fullname) if not auto: self.author_spammer(new_things, True) self.set_last_sr_ban(new_things) queries.ban(all_things, filtered=auto)
def spam(self, things, auto, moderator_banned, banner, date = None, **kw): Report.accept(things, True) things = [ x for x in tup(things) if not x._spam ] for t in things: t._spam = True ban_info = copy(getattr(t, 'ban_info', {})) ban_info.update(auto = auto, moderator_banned = moderator_banned, banner = banner, banned_at = date or datetime.now(g.tz), **kw) t.ban_info = ban_info t._commit() changed(t) self.author_spammer(things, True) queries.ban(things)