Changeset 155
- Timestamp:
- 12/21/10 03:27:55 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm
r148 r155 45 45 if ($needpaste) { 46 46 my $id = $c->forward('/chat/paste', [ 'Bot paste', join("\n", @backup) ]); 47 push(@{ $message->{message} }, 'All results availlable here: ' . $c->uri_for('/chat', $id)); 47 if ($id) { 48 push(@{ $message->{message} }, 'All results availlable here: ' . $c->uri_for('/chat', $id)); 49 } 48 50 } 49 51 … … 75 77 76 78 sub _fmt_location : Private { 77 my ($self, $c, $ pkgid) = @_;79 my ($self, $c, $searchspec, $pkgid) = @_; 78 80 79 81 my @loc; … … 88 90 } 89 91 return join(', ', @loc); 92 } 93 94 sub _find_rpm_elsewhere : Private { 95 my ($self, $c, $searchspec, $name) = @_; 96 if ($searchspec->{distribution}) { 97 my $rpmlist = $c->forward('/search/rpm/byname', [ 98 { 99 distribution => $searchspec->{distribution}, 100 rows => 1, 101 }, $name ]); 102 if (@{$rpmlist}) { 103 return $c->forward('_fmt_location', [ { 104 distribution => $searchspec->{distribution} 105 }, $rpmlist->[0] ]); 106 } 107 } 108 my $rpmlist = $c->forward('/search/rpm/byname', [ {}, $name ]); 109 my %dist; 110 foreach(@$rpmlist) { 111 foreach (@{ $c->forward('/rpms/location', [ $_ ]) }) { 112 $dist{$_->{dist} || $_->{distribution}} = 1; 113 } 114 } 115 if (keys %dist) { 116 return join(', ', sort keys %dist); 117 } 118 return; 90 119 } 91 120 … … 154 183 }, @args ]) }; 155 184 185 if (!$c->forward('/distrib/exists', [ $reqspec ])) { 186 return $c->stash->{xmlrpc} = { 187 message => [ "I don't have such distribution" ] 188 }; 189 } 190 156 191 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 192 if (!@{ $rpmlist }) { 193 my $else = $c->forward('_find_rpm_elsewhere', [ $reqspec, $args[0] ]); 194 if ($else) { 195 return $c->stash->{xmlrpc} = { 196 message => [ 197 "The rpm named `$args[0]' has not been found but found in " . $else 198 ], 199 } 200 } else { 201 return $c->stash->{xmlrpc} = { 202 message => [ "The rpm named `$args[0]' has not been found" ], 203 } 204 } 205 } 157 206 foreach (@{ $rpmlist }) { 158 207 my $info = $c->forward('/rpms/basicinfo', [ $_ ]); 159 208 push @message, $info->{evr} . ' // ' . 160 $c->forward('_fmt_location', [ $ _ ]);209 $c->forward('_fmt_location', [ $reqspec, $_ ]); 161 210 } 162 211 return $c->stash->{xmlrpc} = { … … 333 382 }, @args ]) }; 334 383 384 if (!$c->forward('/distrib/exists', [ $reqspec ])) { 385 return $c->stash->{xmlrpc} = { 386 message => [ "I don't have such distribution" ] 387 }; 388 } 389 335 390 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 391 if (!@{ $rpmlist }) { 392 my $else = $c->forward('_find_rpm_elsewhere', [ $reqspec, $args[0] ]); 393 if ($else) { 394 return $c->stash->{xmlrpc} = { 395 message => [ 396 "The rpm named `$args[0]' has not been found but found in " . $else 397 ], 398 } 399 } else { 400 return $c->stash->{xmlrpc} = { 401 message => [ "The rpm named `$args[0]' has not been found" ], 402 } 403 } 404 } 336 405 foreach (@{ $rpmlist }) { 337 406 my $info = $c->forward('/rpms/queryformat', [ $_, $args[1] ]); 338 407 push @message, $info . ' // ' . 339 $c->forward('_fmt_location', [ $ _ ]);408 $c->forward('_fmt_location', [ $reqspec, $_ ]); 340 409 } 341 410 return $c->stash->{xmlrpc} = { … … 363 432 }, @args ]) }; 364 433 434 if (!$c->forward('/distrib/exists', [ $reqspec ])) { 435 return $c->stash->{xmlrpc} = { 436 message => [ "I don't have such distribution" ] 437 }; 438 } 439 365 440 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 441 if (!@{ $rpmlist }) { 442 my $else = $c->forward('_find_rpm_elsewhere', [ $reqspec, $args[0] ]); 443 if ($else) { 444 return $c->stash->{xmlrpc} = { 445 message => [ 446 "The rpm named `$args[0]' has not been found but found in " . $else 447 ], 448 } 449 } else { 450 return $c->stash->{xmlrpc} = { 451 message => [ "The rpm named `$args[0]' has not been found" ], 452 } 453 } 454 } 366 455 foreach (@{ $rpmlist }) { 367 456 push @message, $c->uri_for('/rpms', $_) . ' // ' . 368 $c->forward('_fmt_location', [ $ _ ]);457 $c->forward('_fmt_location', [ $reqspec, $_ ]); 369 458 } 370 459 return $c->stash->{xmlrpc} = { … … 389 478 'a=s' => \$reqspec->{arch}, 390 479 }, @args ]) }; 480 if (!$c->forward('/distrib/exists', [ $reqspec ])) { 481 return $c->stash->{xmlrpc} = { 482 message => [ "I don't have such distribution" ] 483 }; 484 } 391 485 my $rpmlist = $c->forward('/search/rpm/byname', [ $reqspec, $args[0] ]); 486 if (!@{ $rpmlist }) { 487 my $else = $c->forward('_find_rpm_elsewhere', [ $reqspec, $args[0] ]); 488 if ($else) { 489 return $c->stash->{xmlrpc} = { 490 message => [ 491 "The rpm named `$args[0]' has not been found but found in " . $else 492 ], 493 } 494 } else { 495 return $c->stash->{xmlrpc} = { 496 message => [ "The rpm named `$args[0]' has not been found" ], 497 } 498 } 499 } 392 500 foreach (@{ $rpmlist }) { 393 501 my $res = $c->forward('/rpms/binaries', [ $_ ]);
Note: See TracChangeset
for help on using the changeset viewer.