fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-08-26 02:07 am

[dw-free] http://bugs.dwscoalition.org/show_bug.cgi?id=3790

[commit: http://hg.dwscoalition.org/dw-free/rev/bbbb800a510a]

http://bugs.dwscoalition.org/show_bug.cgi?id=3790

Don't export comments by suspended users. Exception: comments by suspended
users on their own journals.

Patch by [personal profile] exor674.

Files modified:
  • htdocs/export_comments.bml
--------------------------------------------------------------------------------
diff -r ad50bd960700 -r bbbb800a510a htdocs/export_comments.bml
--- a/htdocs/export_comments.bml	Fri Aug 26 10:04:06 2011 +0800
+++ b/htdocs/export_comments.bml	Tue Aug 02 19:18:22 2011 +0800
@@ -84,6 +84,21 @@
         $posterids{$r->[3]} = 1 if $r->[3]; # don't include 0 (anonymous)
     }
 
+    # load posterids
+    my $us = LJ::load_userids( keys %posterids );
+
+    my $userid = $u->userid;
+
+    my $filter = sub {
+        my $data = $_[0];
+        return unless $data->{posterid};
+        return if $data->{posterid} == $userid;
+
+        # If the poster is suspended, we treat the comment as if it was deleted
+        # This comment may have children, so it must still seem to exist.
+        $data->{state} = 'D' if $us->{$data->{posterid}}->is_suspended;
+    };
+
     # now we have two choices: comments themselves or metadata
     if ($mode eq 'comment_meta') {
         # meta data is easy :)
@@ -94,12 +109,12 @@
         $r->print("<maxid>$max</maxid>\n");
         my $nextid = $startid + $gather;
         $r->print("<nextid>$nextid</nextid>\n") unless ($nextid > $max);
-        # load posterids
-        my $us = LJ::load_userids(keys %posterids);
 
         # now spit out the metadata
         $r->print("<comments>\n");
         while (my ($id, $data) = each %comments) {
+            $filter->( $data );
+
             my $ret = "<comment id='$id'";
             $ret .= " posterid='$data->{posterid}'" if $data->{posterid};
             $ret .= " state='$data->{state}'" if $data->{state} ne 'A';
@@ -149,6 +164,8 @@
             my $date = LJ::mysqldate_to_time($data->{datepost});
             $date = LJ::time_to_w3c($date, 'Z');
 
+            $filter->( $data );
+
             # print the data
             my $ret = "<comment id='$id' jitemid='$data->{nodeid}'";
             $ret .= " posterid='$data->{posterid}'" if $data->{posterid};
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org