Ejemplo n.º 1
0
    def unspam(self, things, unbanner=None, train_spam=True, insert=True):
        from r2.lib.db import queries

        things = tup(things)

        # We want to make unban-all moderately efficient, so when
        # mass-unbanning, we're going to skip the code below on links that
        # are already not banned.  However, when someone manually clicks
        # "approve" on an unbanned link, and there's just one, we want do
        # want to run the code below. That way, the little green checkmark
        # will have the right mouseover details, the reports will be
        # cleared, etc.

        if len(things) > 1:
            things = [x for x in things if x._spam]

        Report.accept(things, False)
        for t in things:
            ban_info = copy(getattr(t, 'ban_info', {}))
            ban_info['unbanned_at'] = datetime.now(g.tz)
            if unbanner:
                ban_info['unbanner'] = unbanner
            if ban_info.get('reset_used', None) == None:
                ban_info['reset_used'] = False
            else:
                ban_info['reset_used'] = True
            t.ban_info = ban_info
            t._spam = False
            t._commit()

        self.author_spammer(things, False)
        self.set_last_sr_ban(things)

        queries.unban(things, insert)
Ejemplo n.º 2
0
    def unspam(self,
               things,
               moderator_unbanned=True,
               unbanner=None,
               train_spam=True,
               insert=True):
        from r2.lib.db import queries

        things = tup(things)

        # We want to make unban-all moderately efficient, so when
        # mass-unbanning, we're going to skip the code below on links that
        # are already not banned.  However, when someone manually clicks
        # "approve" on an unbanned link, and there's just one, we want do
        # want to run the code below. That way, the little green checkmark
        # will have the right mouseover details, the reports will be
        # cleared, etc.

        if len(things) > 1:
            things = [x for x in things if x._spam]

        Report.accept(things, False)
        inbox_adjustment_counter = Counter()
        for t in things:
            ban_info = copy(getattr(t, 'ban_info', {}))
            ban_info['unbanned_at'] = datetime.now(g.tz)
            if unbanner:
                ban_info['unbanner'] = unbanner
            if ban_info.get('reset_used', None) == None:
                ban_info['reset_used'] = False
            else:
                ban_info['reset_used'] = True
            t.ban_info = ban_info

            if isinstance(t, Message) and t._spam and t.to_id:
                inbox_adjustment_counter[t.to_id] += 1
            t._spam = False

            if moderator_unbanned:
                t.verdict = 'mod-approved'
            else:
                t.verdict = 'admin-approved'
            t._commit()

            if isinstance(t, Comment):
                amqp.add_item("approved_comment", t._fullname)
            elif isinstance(t, Link):
                amqp.add_item("approved_link", t._fullname)

        self.author_spammer(things, False)
        self.set_last_sr_ban(things)
        queries.unban(things, insert)
        self.adjust_inbox_counts(inbox_adjustment_counter)
Ejemplo n.º 3
0
 def unspam(self, things, unbanner = None):
     Report.accept(things, False)
     things = [ x for x in tup(things) if x._spam ]
     for t in things:
         ban_info = copy(getattr(t, 'ban_info', {}))
         ban_info['unbanned_at'] = datetime.now(g.tz)
         if unbanner:
             ban_info['unbanner'] = unbanner
         t.ban_info = ban_info
         t._spam = False
         t._commit()
         changed(t)
     self.author_spammer(things, False)
     queries.unban(things)
Ejemplo n.º 4
0
    def unspam(self, things, moderator_unbanned=True, unbanner=None,
               train_spam=True, insert=True):
        from r2.lib.db import queries

        things = tup(things)

        # We want to make unban-all moderately efficient, so when
        # mass-unbanning, we're going to skip the code below on links that
        # are already not banned.  However, when someone manually clicks
        # "approve" on an unbanned link, and there's just one, we want do
        # want to run the code below. That way, the little green checkmark
        # will have the right mouseover details, the reports will be
        # cleared, etc.

        if len(things) > 1:
            things = [x for x in things if x._spam]

        Report.accept(things, False)
        inbox_adjustment_counter = Counter()
        for t in things:
            ban_info = copy(getattr(t, 'ban_info', {}))
            ban_info['unbanned_at'] = datetime.now(g.tz)
            if unbanner:
                ban_info['unbanner'] = unbanner
            if ban_info.get('reset_used', None) == None:
                ban_info['reset_used'] = False
            else:
                ban_info['reset_used'] = True
            t.ban_info = ban_info

            if isinstance(t, Message) and t._spam and t.to_id:
                inbox_adjustment_counter[t.to_id] += 1
            t._spam = False

            if moderator_unbanned:
                t.verdict = 'mod-approved'
            else:
                t.verdict = 'admin-approved'
            t._commit()

            if isinstance(t, Comment):
                amqp.add_item("approved_comment", t._fullname)
            elif isinstance(t, Link):
                amqp.add_item("approved_link", t._fullname)

        self.author_spammer(things, False)
        self.set_last_sr_ban(things)
        queries.unban(things, insert)
        self.adjust_inbox_counts(inbox_adjustment_counter)
Ejemplo n.º 5
0
    def unspam(self, things, unbanner = None):
        from r2.lib.db import queries

        things = [x for x in tup(things) if x._spam]
        Report.accept(things, False)
        for t in things:
            ban_info = copy(getattr(t, 'ban_info', {}))
            ban_info['unbanned_at'] = datetime.now(g.tz)
            if unbanner:
                ban_info['unbanner'] = unbanner
            t.ban_info = ban_info
            t._spam = False
            t._commit()
            changed(t)

        # auto is always False for unbans
        self.author_spammer(things, False)
        self.set_last_sr_ban(things)

        queries.unban(things)