ssafronova (ssafronova) wrote in changelog,
ssafronova
ssafronova
changelog

[livejournal] r17586: LJSV-1030: Suspended entries shouldn't b...

Committer: ssafronova
LJSV-1030: Suspended entries shouldn't be considered when displaying recent entries
U   trunk/cgi-bin/LJ/Console/Command/Suspend.pm
U   trunk/cgi-bin/LJ/Console/Command/Unsuspend.pm
U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/ljlib.pl
U   trunk/cgi-bin/ljviews.pl
Modified: trunk/cgi-bin/LJ/Console/Command/Suspend.pm
===================================================================
--- trunk/cgi-bin/LJ/Console/Command/Suspend.pm	2010-10-21 08:43:41 UTC (rev 17585)
+++ trunk/cgi-bin/LJ/Console/Command/Suspend.pm	2010-10-22 03:38:07 UTC (rev 17586)
@@ -51,6 +51,7 @@
             if $entry->is_suspended;
 
         $entry->set_prop( statusvis => "S" );
+        $entry->mark_suspended('S'); # skip in LJ::get_recent_items() call
 
         $reason = "entry: " . $entry->url . "; reason: $reason";
         LJ::statushistory_add($journal, $remote, "suspend", $reason);
@@ -105,6 +106,10 @@
         $self->error($err) 
             unless $u->set_suspended($remote, $reason, \$err);
 
+        my $job = TheSchwartz::Job->new_from_array("LJ::Worker::MarkSuspendedEntries::mark", { userid => $u->userid });
+        my $sclient = LJ::theschwartz();
+        $sclient->insert_jobs($job) if $sclient and $job and LJ::is_enabled('mark_suspended_accounts');
+
         $self->print("User '$username' suspended.");
     }
 

Modified: trunk/cgi-bin/LJ/Console/Command/Unsuspend.pm
===================================================================
--- trunk/cgi-bin/LJ/Console/Command/Unsuspend.pm	2010-10-21 08:43:41 UTC (rev 17585)
+++ trunk/cgi-bin/LJ/Console/Command/Unsuspend.pm	2010-10-22 03:38:07 UTC (rev 17586)
@@ -45,6 +45,8 @@
         $entry->set_prop( unsuspend_supportid => 0 )
             if $entry->prop("unsuspend_supportid");
 
+        $entry->mark_suspended('N'); # return in LJ::get_recent_items() call
+
         $reason = "entry: " . $entry->url . "; reason: $reason";
         LJ::statushistory_add($journal, $remote, "unsuspend", $reason);
         LJ::statushistory_add($poster, $remote, "unsuspend", $reason)
@@ -122,6 +124,10 @@
 
         $u->{statusvis} = $new_status;
 
+        my $job = TheSchwartz::Job->new_from_array("LJ::Worker::MarkSuspendedEntries::unmark", { userid => $u->userid });
+        my $sclient = LJ::theschwartz();
+        $sclient->insert_jobs($job) if $sclient and $job and LJ::is_enabled('mark_suspended_accounts');
+
         LJ::statushistory_add($u, $remote, "unsuspend", $reason);
         eval { $u->fb_push };
         warn "Error running fb_push: $@\n" if $@ && $LJ::IS_DEV_SERVER;

Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2010-10-21 08:43:41 UTC (rev 17585)
+++ trunk/cgi-bin/LJ/Entry.pm	2010-10-22 03:38:07 UTC (rev 17586)
@@ -1327,6 +1327,18 @@
     return 0;
 }
 
+# mark/unmark entry in 'compressed' field to skip/include it in LJ::get_recent_items() call
+sub mark_suspended {
+    my $self = shift;
+    my $value = shift;
+
+    my $u = $self->journal;
+    $u->do("UPDATE log2 SET compressed=? WHERE journalid=? AND jitemid=?",
+           undef, $value, $self->journalid, $self->jitemid);
+    return undef if $u->err;
+    return 1;
+}
+
 package LJ;
 
 use Class::Autouse qw (

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2010-10-21 08:43:41 UTC (rev 17585)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2010-10-22 03:38:07 UTC (rev 17586)
@@ -92,6 +92,7 @@
         'clusterid' => $u->{'clusterid'},
         'clustersource' => 'slave',
         'viewall' => $viewall,
+        'viewsome' => $viewsome,
         'userid' => $u->{'userid'},
         'remote' => $remote,
         'itemshow' => $itemshow + 1,

Modified: trunk/cgi-bin/ljlib.pl
===================================================================
--- trunk/cgi-bin/ljlib.pl	2010-10-21 08:43:41 UTC (rev 17585)
+++ trunk/cgi-bin/ljlib.pl	2010-10-22 03:38:07 UTC (rev 17586)
@@ -980,6 +980,7 @@
 #           -- skip: items to skip
 #           -- itemshow: items to show
 #           -- viewall: if set, no security is used.
+#           -- viewsome: if set, suspended flag is not used
 #           -- dateformat: if "S2", uses S2's 'alldatepart' format.
 #           -- itemids: optional arrayref onto which itemids should be pushed
 #           -- posterid: optional, return (community) posts made by this poster only
@@ -1065,6 +1066,11 @@
         $secwhere = "AND (security='public' OR posterid=$remoteid)";
     }
 
+    my $suspend_where = "";
+    unless ($opts->{'viewall'} || $opts->{'viewsome'}) {
+        $suspend_where = "AND (compressed != 'S' OR posterid = $remoteid)";
+    }
+
     # because LJ::get_friend_items needs rlogtime for sorting.
     my $extra_sql;
     if ($opts->{'friendsview'}) {
@@ -1182,7 +1188,7 @@
                DATE_FORMAT(logtime, "$dateformat") AS 'system_alldatepart',
                allowmask, eventtime, logtime
         FROM log2 USE INDEX ($sort_key)
-        WHERE journalid=$userid $sql_select $secwhere $jitemidwhere $securitywhere $posterwhere
+        WHERE journalid=$userid $sql_select $secwhere $jitemidwhere $securitywhere $posterwhere $suspend_where
         ORDER BY journalid, $sort_key
         $sql_limit
     };

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2010-10-21 08:43:41 UTC (rev 17585)
+++ trunk/cgi-bin/ljviews.pl	2010-10-22 03:38:07 UTC (rev 17586)
@@ -1207,6 +1207,7 @@
         'clusterid' => $u->{'clusterid'},
         'clustersource' => 'slave',
         'viewall' => $viewall,
+        'viewsome' => $viewsome,
         'userid' => $u->{'userid'},
         'remote' => $remote,
         'itemshow' => $itemshow + 1,

Tags: livejournal, pl, pm, ssafronova
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