[livejournal] r23490: LJSUP-14670: XML_RPC addcomment dies ins...
Committer: nnikulochkina
LJSUP-14670: XML_RPC addcomment dies instead of return error messageU trunk/bin/upgrading/en.dat U trunk/cgi-bin/LJ/Test.pm U trunk/cgi-bin/ljprotocol.pl U trunk/etc/lj-api-conf.pl
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat 2012-12-21 06:55:12 UTC (rev 23489)
+++ trunk/bin/upgrading/en.dat 2012-12-21 08:00:55 UTC (rev 23490)
@@ -10745,6 +10745,9 @@
xmlrpc.error.336|staleness=1
xmlrpc.error.336=Account not validated
+xmlrpc.error.337|staleness=1
+xmlrpc.error.337=Not allowed to create comment
+
xmlrpc.error.402|staleness=1
xmlrpc.error.402=Your IP address is temporarily banned for exceeding the login failure rate.
Modified: trunk/cgi-bin/LJ/Test.pm
===================================================================
--- trunk/cgi-bin/LJ/Test.pm 2012-12-21 06:55:12 UTC (rev 23489)
+++ trunk/cgi-bin/LJ/Test.pm 2012-12-21 08:00:55 UTC (rev 23490)
@@ -481,7 +481,7 @@
}
my $subject = delete $opts{subject} || "test suite post.";
- my $body = delete $opts{body} || "This is a test post from $$ at " . time() . "\n";
+ my $body = delete $opts{body} || "This is a test post from $$ at " . time() . "\n" . "with params:" . Dumper(\%opts);
my $props = delete $opts{props} || {};
my %req = (
Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl 2012-12-21 06:55:12 UTC (rev 23489)
+++ trunk/cgi-bin/ljprotocol.pl 2012-12-21 08:00:55 UTC (rev 23490)
@@ -144,6 +144,7 @@
"334" => E_PERM,
"335" => E_PERM,
"336" => E_TEMP,
+ "337" => E_TEMP,
# Limit errors
"402" => E_TEMP,
@@ -554,19 +555,24 @@
my $pk = $req->{prop_picture_keyword} || $req->{picture_keyword};
# create
- my $comment = LJ::Comment->create(
- journal => $journal,
- ditemid => $req->{ditemid},
- parenttalkid => ($req->{parenttalkid} || int($req->{parent} / 256)),
+ my $comment;
+ eval {
+ $comment = LJ::Comment->create(
+ journal => $journal,
+ ditemid => $req->{ditemid},
+ parenttalkid => ($req->{parenttalkid} || int($req->{parent} / 256)),
+
+ poster => $u,
+
+ body => $req->{body},
+ subject => $req->{subject},
+
+ props => { picture_keyword => $pk }
+ );
+ };
- poster => $u,
+ return fail($err,337) unless $comment;
- body => $req->{body},
- subject => $req->{subject},
-
- props => { picture_keyword => $pk }
- );
-
## Counter "new_comment" for monitoring
LJ::run_hook ("update_counter", {
counter => "new_comment",
Modified: trunk/etc/lj-api-conf.pl
===================================================================
--- trunk/etc/lj-api-conf.pl 2012-12-21 06:55:12 UTC (rev 23489)
+++ trunk/etc/lj-api-conf.pl 2012-12-21 08:00:55 UTC (rev 23490)
@@ -22,6 +22,7 @@
sessionexpire => 0,
sessiongenerate => 0,
syncitems => 0,
+ addcomment => 1,
);
%LJ::XMLRPC_USER_ACCESS = (
