changelog_bot (changelog_bot) wrote in changelog,
changelog_bot
changelog_bot
changelog

[livejournal] r23389: LJSUP-14237: Suspend user if he posts mo...

Committer: tnurutdinov
LJSUP-14237: Suspend user if he posts more that 3 comments with url from spam list
U   trunk/cgi-bin/LJ/Talk/Post.pm
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/Talk/Post.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk/Post.pm	2012-11-29 10:17:12 UTC (rev 23388)
+++ trunk/cgi-bin/LJ/Talk/Post.pm	2012-11-29 10:23:23 UTC (rev 23389)
@@ -181,19 +181,38 @@
         LJ::MemCache::set([$journalu->{'userid'}, "talkprop:$journalu->{'userid'}:$jtalkid"], $hash);
     }
 
-    # record up to 25 (or $LJ::TALK_MAX_URLS) urls from a comment
-    if ($LJ::TALK_MAX_URLS) {
-        my %urls = map { $_ => 1 } LJ::get_urls($comment->{body});
+    my %urls = map { $_ => 1 } LJ::get_urls($comment->{body});
+    my @urls = keys %urls;
 
+    # record up to $LJ::TALK_MAX_URLS urls from a comment
+    if ($LJ::TALK_MAX_URLS && @urls) {
         LJ::Admin::Spam::Urls::insert(
             $posterid,
             $journalu->{userid},
             $jtalkid,
             $comment->{state} eq 'B' ? 'S' : '',
-            keys %urls
+            @urls
         );
     }
 
+    # update the "spam_counter" if URL is in TOP of spam URLs for the last 24 hour
+    # and comment mark as spam
+    if ($comment->{state} eq 'B') {
+        my $change = 0;
+
+        foreach my $url (@urls) {
+            if (LJ::Admin::Spam::Urls::is_url_in_top_of_spam($url)) {
+                $change++;
+            }
+        }
+
+        if ($change) {
+            if (my $u = $comment->{u}) {
+                $u->incr_spam_counter($change);
+            }
+        }
+    }
+
     # update the "replycount" summary field of the log table
     if ($comment->{state} eq 'A') {
         LJ::replycount_do($journalu, $itemid, "incr", 1, $posterid);

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-11-29 10:17:12 UTC (rev 23388)
+++ trunk/cgi-bin/LJ/User.pm	2012-11-29 10:23:23 UTC (rev 23389)
@@ -6635,6 +6635,31 @@
     return $u->prop('promo_announce_disabled') || 0;
 }
 
+sub incr_spam_counter {
+    my ($u, $value) = @_;
+
+    unless ($value) {
+        return;
+    }
+
+    unless ($value =~ /^\d+$/) {
+        return;
+    }
+
+    my $spam_counter = ($u->prop('spam_counter') || 0) + $value;
+
+    $u->set_prop('spam_counter', $spam_counter);
+
+    LJ::run_hooks('user_spam_counter_incr', $u, $spam_counter);
+
+    return $spam_counter;
+}
+
+sub clear_spam_counter {
+    my ($u) = @_;
+    $u->set_prop('spam_counter', 0);
+}
+
 package LJ;
 
 use Carp;
@@ -10964,6 +10989,5 @@
     }
 
 }
-
     
 1;

Tags: livejournal, pm, tnurutdinov
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments