Committer: nnikulochkina
LJSUP-11873: need to add a check for dtalkidFixed in LJ.XMLRPC.deletecomments and LJ.XMLRPC.updatecomments
U trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/ljprotocol.pl =================================================================== --- trunk/cgi-bin/ljprotocol.pl 2012-04-20 08:16:54 UTC (rev 21760) +++ trunk/cgi-bin/ljprotocol.pl 2012-04-20 08:31:32 UTC (rev 21761) @@ -803,13 +803,14 @@ push @ids, $num; } - my @comments = map { LJ::Comment->new($journal, dtalkid => $_) } @ids; - - foreach my $comm (@comments) { - return fail($err, 203, 'xmlrpc.des.no_comment_by_param',{'param'=>'dtalkid'}) unless $comm->valid; + my @comments; + foreach my $id (@ids) { + my $comm = LJ::Comment->new($journal, dtalkid => $id); + return fail($err, 203, 'xmlrpc.des.no_comment_by_param',{'param'=>'dtalkid'}) unless $comm->dtalkid == $id; return fail($err, 327, 'dtalkid:'.$comm->dtalkid) if $comm->is_deleted; return fail($err, 326, 'dtalkid:'.$comm->dtalkid) unless $comm->user_can_delete($u); - } + push @comments, $comm; + } my @to_delete; if(!$req->{thread}){ @@ -883,10 +884,13 @@ my $can_method = ($action =~ /spam|unspam/ ? ($action eq 'spam' ? "LJ::Talk::can_marked_as_spam" : "LJ::Talk::can_unmark_spam") : "LJ::Talk::can_$action"); $can_method = \&{$can_method}; - my @comments = map { LJ::Comment->new($journal, dtalkid => $_) } @ids; - foreach my $comm (@comments) { + my @comments; + foreach my $id (@ids) { + my $comm = LJ::Comment->new($journal, dtalkid => $id); + return fail($err, 203, 'xmlrpc.des.no_comment_by_param',{'param'=>'dtalkid'}) unless $comm->dtalkid == $id; return fail($err, 326, 'dtalkid:'.$comm->dtalkid) unless $can_method->($u, $journal, $comm->entry->poster, $comm->poster); - } + push @comments, $comm; + } # get first entry my $jitemid = $comments[0]->entry->jitemid;