mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-08-31 09:27 pm

[dw-free] This provides initial support for importing communities. Right now, this is restricted so

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

This provides initial support for importing communities. Right now, this is
restricted so that we have to approve people to import communities, it is
not available for everyone. This also introduces a very firm
importer_bypass option to postevent, allowing us to try really hard to post
an entry.

Patch by [staff profile] mark.

Files modified:
  • bin/upgrading/en.dat
  • bin/upgrading/update-db-general.pl
  • cgi-bin/DW/Logic/Importer.pm
  • cgi-bin/DW/Worker/ContentImporter.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm
  • cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm
  • cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm
  • cgi-bin/LJ/Widget/ImportChooseSource.pm
  • cgi-bin/LJ/Widget/ImportConfirm.pm
  • cgi-bin/ljprotocol.pl
--------------------------------------------------------------------------------
diff -r cbef12206273 -r b5bf8561aab5 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Mon Aug 31 09:03:41 2009 +0000
+++ b/bin/upgrading/en.dat	Mon Aug 31 21:27:13 2009 +0000
@@ -4188,6 +4188,8 @@ widget.importchoosesource.password=Passw
 
 widget.importchoosesource.service=Choose a service to import from:
 
+widget.importchoosesource.usejournal=Community on other service
+
 widget.importchoosesource.username=Username on other service
 
 widget.importchoosesource.warning=Warning: You have another import currently in progress. Setting up a new import will abort your current import!
@@ -4203,6 +4205,8 @@ widget.importconfirm.items=<strong>Data 
 widget.importconfirm.items=<strong>Data that you are importing:</strong><br />[[items]]
 
 widget.importconfirm.source=<strong>Importing from:</strong><br />[[user]] at [[host]]
+
+widget.importconfirm.source.comm=<strong>Importing from:</strong><br />[[comm]] (authenticated as [[user]]) at [[host]]
 
 widget.importconfirm.warning=Warning: Once confirmed, you cannot stop or reverse an import!
 
diff -r cbef12206273 -r b5bf8561aab5 bin/upgrading/update-db-general.pl
--- a/bin/upgrading/update-db-general.pl	Mon Aug 31 09:03:41 2009 +0000
+++ b/bin/upgrading/update-db-general.pl	Mon Aug 31 21:27:13 2009 +0000
@@ -2972,6 +2972,7 @@ CREATE TABLE import_data (
     import_data_id INT UNSIGNED NOT NULL,
     hostname VARCHAR(255),
     username VARCHAR(255),
+    usejournal VARCHAR(255),
     password_md5 VARCHAR(255),
     groupmap BLOB,
 
@@ -3940,6 +3941,11 @@ register_alter(sub {
         set_dbnote( "userprop_ljcut_to_cut", 1 );
     }
 
+    unless ( column_type( 'import_data', 'usejournal' ) ) {
+        do_alter( 'import_data',
+                  q{ALTER TABLE import_data ADD COLUMN usejournal VARCHAR(255) AFTER username} );
+    }
+
 });
 
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Logic/Importer.pm
--- a/cgi-bin/DW/Logic/Importer.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Logic/Importer.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -29,7 +29,7 @@ sub get_import_data_for_user {
     # load up their most recent (active) import
     # FIXME: memcache this
     my $imports = $dbh->selectall_arrayref(
-        'SELECT import_data_id, hostname, username, password_md5 FROM import_data WHERE userid = ? ' .
+        'SELECT import_data_id, hostname, username, usejournal, password_md5 FROM import_data WHERE userid = ? ' .
         'ORDER BY import_data_id DESC LIMIT 1',
         undef, $u->id
     );
@@ -47,8 +47,8 @@ sub get_import_items_for_user {
 
     my $has_items = 0;
     foreach my $import ( @$imports ) {
-        my ( $importid, $host, $username, $password ) = @$import;
-        $items{$importid} = { host => $host, user => $username, pw => $password, items => {} };
+        my ( $importid, $host, $username, $usejournal, $password ) = @$import;
+        $items{$importid} = { host => $host, user => $username, pw => $password, usejournal => $usejournal, items => {} };
 
         my $import_items = $dbh->selectall_arrayref(
             'SELECT item, status, created, last_touch FROM import_items WHERE userid = ? AND import_data_id = ?',
@@ -72,6 +72,7 @@ sub set_import_data_for_user {
     my $hn = $opts{hostname};
     my $un = $opts{username};
     my $pw = $opts{password};
+    my $uj = $opts{usejournal};
 
     return "Did not pass hostname, username, and password."
         unless $hn && $un && $pw;
@@ -81,8 +82,8 @@ sub set_import_data_for_user {
 
     my $id = LJ::alloc_user_counter( $u, "I" ) or return "Can't get id for import data.";
     $dbh->do(
-        "INSERT INTO import_data (userid, import_data_id, hostname, username, password_md5) VALUES (?, ?, ?, ?, ?)",
-        undef, $u->id, $id, $hn, $un, md5_hex( $pw )
+        "INSERT INTO import_data (userid, import_data_id, hostname, username, usejournal, password_md5) VALUES (?, ?, ?, ?, ?, ?)",
+        undef, $u->id, $id, $hn, $un, $uj, md5_hex( $pw )
     );
     return $dbh->errstr if $dbh->err;
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter.pm
--- a/cgi-bin/DW/Worker/ContentImporter.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -96,7 +96,7 @@ sub import_data {
 
     my $dbh = LJ::get_db_writer()
         or croak 'unable to get global database master';
-    my $hr = $dbh->selectrow_hashref( 'SELECT userid, hostname, username, password_md5, import_data_id ' .
+    my $hr = $dbh->selectrow_hashref( 'SELECT userid, hostname, username, usejournal, password_md5, import_data_id ' .
                                       'FROM import_data WHERE userid = ? AND import_data_id = ?', undef, $userid, $impid );
     croak $dbh->errstr if $dbh->err;
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -372,11 +372,16 @@ sub call_xmlrpc {
 
     my $response = md5_hex( $chal . ( $opts->{md5password} || $opts->{password_md5} || md5_hex( $opts->{password} ) ) );
 
+    # we have to do this like this so that we don't send the argument if it's not valid
+    my %usejournal;
+    $usejournal{usejournal} = $opts->{usejournal} if $opts->{usejournal};
+
     my $res = $class->xmlrpc_call_helper( $opts, $xmlrpc, "LJ.XMLRPC.$mode", {
         username       => $opts->{user} || $opts->{username},
         auth_method    => 'challenge',
         auth_challenge => $chal,
         auth_response  => $response,
+        %usejournal,
         %{ $hash || {} },
     }, $mode, $hash, $depth );
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Bio.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -61,7 +61,8 @@ sub try_work {
 # FIXME: have to flip this back to using the user_path value instead of hardcoded
 # livejournal.com ... this should probably be part of the import_data structure?
 # abstract out sites?
-    my ( $items, $interests, $schools ) = $class->get_foaf_from( "http://$data->{username}.$data->{hostname}/data/foaf" );
+    my $un = $data->{usejournal} || $data->{username};
+    my ( $items, $interests, $schools ) = $class->get_foaf_from( "http://$un.$data->{hostname}/data/foaf" );
     return $temp_fail->( 'Unable to load FOAF data' )
         unless $items;
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Comments.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -113,13 +113,15 @@ sub try_work {
         $turl =~ s/-/_/g; # makes \b work below
         $log->( 'Filtering entry URL: %s', $turl );
         next unless $turl =~ /\Q$data->{hostname}\E/ &&
-                    $turl =~ /\b$data->{username}\b/;
+                    ( $turl =~ /\b$data->{username}\b/ ||
+                        ( $data->{usejournal} && $turl =~ /\b$data->{usejournal}\b/ ) );
 
         my $jitemid = $1 >> 8
             if $url =~ m!/(\d+)\.html$!;
         $jitemid_map->{$jitemid} = $entry_map->{$url};
         $entry_source->{$jitemid_map->{$jitemid}} = $url;
     }
+    $log->( 'Entry map has %d entries post-prune.', scalar( keys %$entry_map ) );
 
     foreach my $jitemid ( keys %$xpost_map ) {
         $jitemid_map->{$jitemid} = $xpost_map->{$jitemid};
@@ -138,7 +140,8 @@ sub try_work {
         $turl =~ s/-/_/g; # makes \b work below
         $log->( 'Filtering comment URL: %s', $turl );
         next unless $turl =~ /\Q$data->{hostname}\E/ &&
-                    $turl =~ /\b$data->{username}\b/;
+                    ( $turl =~ /\b$data->{username}\b/ ||
+                        ( $data->{usejournal} && $turl =~ /\b$data->{usejournal}\b/ ) );
 
         my $jtalkid = $1 >> 8
             if $url =~ m!thread=(\d+)$!;
@@ -443,7 +446,8 @@ sub do_authed_comment_fetch {
 
     # hit up the server with the specified information and return the raw content
     my $ua = LWP::UserAgent->new;
-    my $request = HTTP::Request->new( GET => "http://www.$data->{hostname}/export_comments.bml?get=$mode&startid=$startid&numitems=$numitems" );
+    my $authas = $data->{usejournal} ? "&authas=$data->{usejournal}" : '';
+    my $request = HTTP::Request->new( GET => "http://www.$data->{hostname}/export_comments.bml?get=$mode&startid=$startid&numitems=$numitems$authas" );
     $request->push_header( Cookie => "ljsession=$data->{_session}" );
 
     # try to get the response
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Entries.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -46,9 +46,9 @@ sub try_work {
     my ( $class, $job, $opts, $data ) = @_;
     my $begin_time = [ gettimeofday() ];
 
-    # we know that we can potentially take a while, so budget a few hours for
+    # we know that we can potentially take a while, so budget an hour for
     # the import job before someone else comes in to snag it
-    $job->grabbed_until( time() + 3600*12 );
+    $job->grabbed_until( time() + 3600 );
     $job->save;
 
     # failure wrappers for convenience
@@ -177,6 +177,9 @@ sub try_work {
         return $sync{$id}->[1] if @{$sync{$id} || []};
     };
 
+    # helper so we don't have to get so much FOAF data
+    my %user_map;
+
     # now get the actual events
     while ( scalar( keys %sync ) > 0 ) {
         my ( $count, $last_itemid ) = ( 0, undef );
@@ -210,13 +213,34 @@ sub try_work {
                 $newmask = 0;
                 push @item_errors, "Could not determine groups to post to.";
             }
-
             $evt->{allowmask} = $newmask;
 
-            my $event = $evt->{event};
+            # now try to determine if we need to post this as a user
+            my $posteru;
+            if ( $evt->{poster} && $evt->{poster} ne $data->{username} ) {
+                my $posterid = exists $user_map{$evt->{poster}} ? $user_map{$evt->{poster}} :
+                    DW::Worker::ContentImporter::LiveJournal->remap_username_friend( $data, $evt->{poster} );
+
+                unless ( $posterid ) {
+                    # set it to 0, but exists, so we don't hit LJ again, but we continue to fail this poster
+                    $user_map{$evt->{poster}} = 0;
+
+                    # FIXME: need a better way of totally dying...
+                    push @item_errors, "Unable to map poster from LJ user '$evt->{poster}' to local user.";
+                    $status->(
+                        remote_url => $evt->{url},
+                        errors     => \@item_errors,
+                    );
+                    return;
+                }
+
+                $user_map{$evt->{poster}} ||= $posterid;
+                $posteru = LJ::load_userid( $posterid );
+            }
 
             # we just link polls to the original site
 # FIXME: this URL should be from some method and not manually constructed
+            my $event = $evt->{event};
             $event =~ s!<.+?-poll-(\d+?)>![<a href="http://www.$data->{hostname}/poll/?id=$1">Poll #$1</a>]!g;
 
             if ( $event =~ m/<.+?-embed-.+?>/ ) {
@@ -235,7 +259,7 @@ sub try_work {
 
             # actually post it
             my ( $ok, $res ) =
-                DW::Worker::ContentImporter::Local::Entries->post_event( $data, $entry_map, $u, $evt, \@item_errors );
+                DW::Worker::ContentImporter::Local::Entries->post_event( $data, $entry_map, $u, $posteru, $evt, \@item_errors );
 
             # now record any errors that happened
             $status->(
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Friends.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -45,6 +45,10 @@ sub try_work {
     my $ok        = sub { return $class->ok( $data, 'lj_friends', $job ); };
     my $temp_fail = sub { return $class->temp_fail( $data, 'lj_friends', $job, @_ ); };
 
+    # if this is a usejournal request, we have no friends (it's a comm or something) so
+    # bail very early
+    return $ok->() if $data->{usejournal};
+
     # setup
     my $u = LJ::load_userid( $data->{userid} )
         or return $fail->( 'Unable to load target with id %d.', $data->{userid} );
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm
--- a/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/LiveJournal/Userpics.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -83,7 +83,8 @@ sub try_work {
     $0 = sprintf( 'content-importer [userpics: %s(%d)]', $u->user, $u->id );
 
 # FIXME: URL may not be accurate here for all sites
-    my ( $default, @pics ) = $class->get_lj_userpic_data( "http://$data->{hostname}/users/$data->{username}/", $data, $log );
+    my $un = $data->{usejournal} || $data->{username};
+    my ( $default, @pics ) = $class->get_lj_userpic_data( "http://$data->{hostname}/users/$un/", $data, $log );
 
     my $errs = [];
     my @imported = DW::Worker::ContentImporter::Local::Userpics->import_userpics( $u, $errs, $default, \@pics, $log );
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm
--- a/cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/DW/Worker/ContentImporter/Local/Entries.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -86,7 +86,7 @@ Returns (1, $res) on success, (undef, $r
 =cut
 
 sub post_event {
-    my ( $class, $data, $map, $u, $evt, $errors ) = @_;
+    my ( $class, $data, $map, $u, $posteru, $evt, $errors ) = @_;
 
     return if $map->{$evt->{key}};
 
@@ -115,6 +115,7 @@ sub post_event {
         current_coords => 1,
         personifi_word_count => 1,
         personifi_lang => 1,
+        personifi_tags => 1,
     );
     foreach my $prop ( keys %$props ) {
         next if $bad_props{$prop};
@@ -134,17 +135,16 @@ sub post_event {
     LJ::do_request(
         {
             mode => 'postevent',
-            user => $u->user,
+            user => $posteru ? $posteru->user : $u->user,
+            usejournal => $posteru ? $u->user : undef,
             ver  => $LJ::PROTOCOL_VER,
             %proto,
         },
         \%res,
         {
-            u => $u,
-            noauth => 1,
-            nonotify => 1,
-            ignore_tags_max => 1,
-            allow_inactive => 1,
+            u => $posteru || $u,
+            u_owner => $u,
+            importer_bypass => 1,
         }
     );
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/LJ/Widget/ImportChooseSource.pm
--- a/cgi-bin/LJ/Widget/ImportChooseSource.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/LJ/Widget/ImportChooseSource.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -85,6 +85,12 @@ sub render_body {
     $ret .= "<label for='password'>" . $class->ml( 'widget.importchoosesource.password' ) . "</label>";
     $ret .= $class->html_text( type => 'password', name => 'password' );
     $ret .= "</div>";
+    if ( $LJ::ALLOW_COMM_IMPORT{$u->user} ) {
+        $ret .= "<div class='i-usejournal'>";
+        $ret .= "<label for='usejournal'>" . $class->ml( 'widget.importchoosesource.usejournal' ) . "</label>";
+        $ret .= $class->html_text( name => 'usejournal', maxlength => 255 );
+        $ret .= "</div>";
+    }
     $ret .= "</div>";
 
     $ret .= $class->html_submit( submit => $class->ml( 'widget.importchoosesource.btn.continue' ) );
@@ -107,11 +113,18 @@ sub handle_post {
     my $un = LJ::trim( lc $post->{username} );
     $un =~ s/-/_/g;
 
+    # be sure to sanitize the usejournal
+    my $uj = undef;
+    if ( $LJ::ALLOW_COMM_IMPORT{$u->user} ) {
+        $uj = LJ::trim( lc $post->{usejournal} );
+        $uj =~ s/-/_/g;
+    }
+
     my $pw = $post->{password};
     return ( ret => $class->ml( 'widget.importchoosesource.error.nocredentials' ) )
         unless $un && $pw;
 
-    if ( my $error = DW::Logic::Importer->set_import_data_for_user( $u, hostname => $hn, username => $un, password => $pw ) ) {
+    if ( my $error = DW::Logic::Importer->set_import_data_for_user( $u, hostname => $hn, username => $un, password => $pw, usejournal => $uj ) ) {
         return ( ret => $error );
     }
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/LJ/Widget/ImportConfirm.pm
--- a/cgi-bin/LJ/Widget/ImportConfirm.pm	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/LJ/Widget/ImportConfirm.pm	Mon Aug 31 21:27:13 2009 +0000
@@ -45,7 +45,11 @@ sub render_body {
     $ret .= "<p>" . $class->ml( 'widget.importconfirm.intro' ) . "</p>";
 
     my $imports = DW::Logic::Importer->get_import_data_for_user( $u );
-    $ret .= "<p>" . $class->ml( 'widget.importconfirm.source', { user => $imports->[0]->[2], host => $imports->[0]->[1] } ) . "</p>";
+    if ( $imports->[0]->[3] ) {
+        $ret .= "<p>" . $class->ml( 'widget.importconfirm.source.comm', { user => $imports->[0]->[2], host => $imports->[0]->[1], comm => $imports->[0]->[3] } ) . "</p>";
+    } else {
+        $ret .= "<p>" . $class->ml( 'widget.importconfirm.source', { user => $imports->[0]->[2], host => $imports->[0]->[1] } ) . "</p>";
+    }
     $ret .= "<p>" . $class->ml( 'widget.importconfirm.destination', { user => $u->ljuser_display, host => $LJ::SITENAMESHORT } ) . "</p>";
     $ret .= "<p>" . $class->ml( 'widget.importconfirm.items', { items => join( '<br />', @items_display ) } ) . "</p>";
 
diff -r cbef12206273 -r b5bf8561aab5 cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl	Mon Aug 31 09:03:41 2009 +0000
+++ b/cgi-bin/ljprotocol.pl	Mon Aug 31 21:27:13 2009 +0000
@@ -990,6 +990,20 @@ sub postevent
     my ($req, $err, $flags) = @_;
     un_utf8_request($req);
 
+    # if the importer is calling us, we want to allow it to post in all but the most extreme
+    # of cases.  and even then, we try our hardest to allow content to be posted.  setting this
+    # flag will bypass a lot of the safety restrictions about who can post where and when, so
+    # we trust the importer to be intelligent about this.  (And if you aren't the importer, don't
+    # use this option!!!)
+    my $importer_bypass = $flags->{importer_bypass} ? 1 : 0;
+    if ( $importer_bypass ) {
+        $flags->{nomod} = 1;
+        $flags->{ignore_tags_max} = 1;
+        $flags->{nonotify} = 1;
+        $flags->{noauth} = 1;
+        $flags->{usejournal_okay} = 1;
+    }
+
     return undef unless LJ::run_hook('post_noauth', $req) || authenticate($req, $err, $flags);
 
     # if going through mod queue, then we know they're permitted to post at least this entry
@@ -998,6 +1012,7 @@ sub postevent
     my $u = $flags->{'u'};
     my $ownerid = $flags->{'ownerid'}+0;
     my $uowner = $flags->{'u_owner'} || $u;
+
     # Make sure we have a real user object here
     $uowner = LJ::want_user($uowner) unless LJ::isu($uowner);
     my $clusterid = $uowner->{'clusterid'};
@@ -1009,22 +1024,23 @@ sub postevent
     return fail($err,200) unless $req->{'event'} =~ /\S/;
 
     ### make sure community or identity journals don't post
-    return fail($err,150) if $u->is_community || $u->is_identity;
+    return fail($err,150) if $u->is_community;
+    return fail($err,150) if ! $importer_bypass && $u->is_identity;
 
     # suspended users can't post
-    return fail($err,305) if $u->is_suspended;
+    return fail($err,305) if ! $importer_bypass && $u->is_suspended;
 
     # memorials can't post
-    return fail($err,309) if $u->is_memorial;
+    return fail($err,309) if ! $importer_bypass && $u->is_memorial;
 
     # locked accounts can't post
-    return fail($err,308) if $u->is_locked;
+    return fail($err,308) if ! $importer_bypass && $u->is_locked;
 
     # check the journal's read-only bit
     return fail($err,306) if LJ::get_cap($uowner, "readonly");
 
     # is the user allowed to post?
-    return fail($err,404,$LJ::MSG_NO_POST) unless LJ::get_cap($u, "can_post");
+    return fail($err,404,$LJ::MSG_NO_POST) unless $importer_bypass || LJ::get_cap($u, "can_post");
 
     # is the user allowed to post?
     return fail($err,410) if LJ::get_cap($u, "disable_can_post");
@@ -1036,7 +1052,7 @@ sub postevent
     return fail($err,317) if $uowner->is_readonly;
 
     # can't post to deleted/suspended community
-    return fail($err,307) unless $uowner->is_visible;
+    return fail($err,307) unless $importer_bypass || $uowner->is_visible;
 
     # must have a validated email address to post to a community
     # unless this is approved from the mod queue (we'll error out initially, but in case they change later)
@@ -1079,7 +1095,7 @@ sub postevent
     # confirm we can add tags, at least
     return fail($err, 312)
         if $req->{props} && $req->{props}->{taglist} &&
-           ! LJ::Tags::can_add_tags($uowner, $u);
+           ! ( $importer_bypass || LJ::Tags::can_add_tags( $uowner, $u ) );
 
     my $event = $req->{'event'};
 
@@ -1150,8 +1166,8 @@ sub postevent
 
     # don't allow backdated posts in communities
     return fail($err,152) if
-        ($req->{'props'}->{"opt_backdated"} &&
-         ! $uowner->is_person);
+        ( $req->{props}->{opt_backdated} &&
+         ! ( $importer_bypass || $uowner->is_person ) );
 
     # do processing of embedded polls (doesn't add to database, just
     # does validity checking)
@@ -1335,7 +1351,7 @@ sub postevent
     $getlock->(); return $res if $res_done;
 
     # do rate-checking
-    if ( ! $u->is_syndicated && ! LJ::rate_log($u, "post", 1) ) {
+    if ( ! $u->is_syndicated && ! LJ::rate_log($u, "post", 1) && ! $importer_bypass ) {
         return $fail->($err,405);
     }
 
@@ -1433,6 +1449,7 @@ sub postevent
         my $logtag_opts = {
             remote => $u,
             ignore_max => $flags->{ignore_tags_max} ? 1 : 0,
+            force => $importer_bypass,
             err_ref => \$tagerr,
         };
 
--------------------------------------------------------------------------------

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