Patch by mark.
diffs (177 lines):
diff -r 08c8842ed39b -r 4828af364826 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat Sat May 09 07:20:41 2009 +0000
+++ b/bin/upgrading/en.dat Sat May 09 07:27:30 2009 +0000
@@ -1941,15 +1941,15 @@ event.userpic_upload.me=One of the accou
event.userpic_upload.user=[[user]] uploads a new userpic
-event.xpost.failure.content=Crosspost to [[accountname]] failed.
-
-event.xpost.failure.title=Crosspost of <a href =
"[[entryurl]]">[[entrydesc]]</a> to [[accountname]] action failed.
+event.xpost.failure.content=Crosspost to [[accountname]] failed.<br /><br
/>[[errmsg]]
+
+event.xpost.failure.title=Crosspost of <a
href="[[entryurl]]">[[entrydesc]]</a> to [[accountname]] action failed.
event.xpost.nosubject=an entry
event.xpost.success.content=Crosspost to [[accountname]] successful.
-event.xpost.success.title=Crosspost of <a href =
"[[entryurl]]">[[entrydesc]]</a> to [[accountname]] action successful.
+event.xpost.success.title=Crosspost of <a
href="[[entryurl]]">[[entrydesc]]</a> to [[accountname]] action successful.
fckland.ljimage=Insert/Edit Image
@@ -4579,7 +4579,7 @@ xpost.delete.success=Crossposted entry a
xpost.edit.error=Failed to update crossposted entry at
[[usernam...@[[server]]: [[error]]
-xpost.edit.success=Update of crosspost at [[usernam...@[[server]] successful.
You can view this edited entry <a href = "[[xpostlink]]">here</a>.
+xpost.edit.success=Update of crosspost at [[usernam...@[[server]] successful.
You can view this edited entry <a href="[[xpostlink]]">here</a>.
xpost.error=Failed to crosspost entry to [[usernam...@[[server]]: [[error]]
diff -r 08c8842ed39b -r 4828af364826 cgi-bin/DW/Worker/XPostWorker.pm
--- a/cgi-bin/DW/Worker/XPostWorker.pm Sat May 09 07:20:41 2009 +0000
+++ b/cgi-bin/DW/Worker/XPostWorker.pm Sat May 09 07:27:30 2009 +0000
@@ -80,7 +80,11 @@ sub work {
if ($result->{success}) {
$sclient->insert_jobs(LJ::Event::XPostSuccess->new($u, $acctid,
$ditemid)->fire_job );
} else {
- $sclient->insert_jobs(LJ::Event::XPostFailure->new($u, $acctid,
$ditemid)->fire_job );
+ $sclient->insert_jobs(
+ LJ::Event::XPostFailure->new(
+ $u, $acctid, $ditemid, ( $result->{error} || 'Unknown error
message.' )
+ )->fire_job
+ );
}
$job->completed;
diff -r 08c8842ed39b -r 4828af364826 cgi-bin/LJ/Event/XPostFailure.pm
--- a/cgi-bin/LJ/Event/XPostFailure.pm Sat May 09 07:20:41 2009 +0000
+++ b/cgi-bin/LJ/Event/XPostFailure.pm Sat May 09 07:27:30 2009 +0000
@@ -6,6 +6,7 @@
#
# Authors:
# Allen Petersen <[email protected]>
+# Mark Smith <[email protected]>
#
# Copyright (c) 2009 by Dreamwidth Studios, LLC.
#
@@ -16,12 +17,32 @@ package LJ::Event::XPostFailure;
package LJ::Event::XPostFailure;
use strict;
use base 'LJ::Event';
-use Carp qw(croak);
+use Carp qw/ croak /;
+use Storable qw/ nfreeze thaw /;
sub new {
- my ($class, $u, $ditemid, $acctid) = @_;
- croak 'Not an LJ::User' unless LJ::isu($u);
- return $class->SUPER::new($u, $ditemid, $acctid);
+ my ( $class, $u, $acctid, $ditemid, $errmsg ) = @_;
+ $u = LJ::want_user( $u )
+ or croak 'Invalid LJ::User object passed.';
+
+ # we're overloading the import_status table. they won't notice.
+ my $sid = LJ::alloc_user_counter( $u, 'Z' );
+ if ( $sid ) {
+ # build the ref we'll store
+ my $optref = {
+ ditemid => $ditemid+0,
+ acctid => $acctid+0,
+ errmsg => $errmsg,
+ };
+
+ # now attempt to store it
+ $u->do( 'INSERT INTO import_status (userid, import_status_id, status)
VALUES (?, ?, ?)',
+ undef, $u->id, $sid, nfreeze( $optref ) );
+ return $class->SUPER::new( $u, $sid );
+ }
+
+ # we failed somewhere
+ return undef;
}
# for this to be on for all users
@@ -35,10 +56,13 @@ sub always_checked { 1 }
sub always_checked { 1 }
-# FIXME make this more useful, like include the failure message
sub content {
- my ($self) = @_;
- return BML::ml('event.xpost.failure.content', { accountname =>
$self->account->displayname });
+ my $self = $_[0];
+ return BML::ml( 'event.xpost.failure.content',
+ {
+ accountname => $self->account->displayname,
+ errmsg => $self->errmsg,
+ } );
}
# the main title for the event
@@ -95,29 +119,53 @@ sub get_subscriptions {
return $self->SUPER::get_subscriptions($u, $subid);
}
+
sub acctid {
- return $_[0]->arg1;
+ return $_[0]->_optsref->{acctid};
}
+
sub ditemid {
- return $_[0]->arg2;
+ return $_[0]->_optsref->{ditemid};
}
+
+
+sub errmsg {
+ return $_[0]->_optsref->{errmsg};
+}
+
# the account crossposted to
sub account {
- my ($self) = @_;
- return $_[0]->{account} if $_[0]->{account};
- $_[0]->{account} = DW::External::Account->get_external_account($self->u,
$self->acctid);
- return $_[0]->{account};
+ my $self = $_[0];
+ return $self->{account} ||=
+ DW::External::Account->get_external_account( $self->u, $self->acctid );
}
+
# the entry crossposted
sub entry {
- my ($self) = @_;
- return $self->{entry} if $self->{entry};
- $_[0]->{entry} = LJ::Entry->new($self->u, ( ditemid => $self->ditemid ));
- return $self->{entry};
+ my $self = $_[0];
+ return $self->{entry} ||= LJ::Entry->new( $self->u, ditemid =>
$self->ditemid );
}
+# load our options hashref which contains most of the information we
+# are actually interested in
+sub _optsref {
+ my $self = $_[0];
+ return $self->{_optsref} if $self->{_optsref};
+
+ my $u = $self->u;
+ my $item = $u->selectrow_array(
+ 'SELECT status FROM import_status WHERE userid = ? AND
import_status_id = ?',
+ undef, $u->id, $self->arg1
+ );
+ return undef
+ if $u->err || ! $item;
+
+ return $self->{_optsref} = thaw( $item );
+}
+
+
1;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog