|
|
@ -29,8 +29,7 @@ sub captcha { |
|
|
|
} or do { |
|
|
|
} or do { |
|
|
|
chomp $@; |
|
|
|
chomp $@; |
|
|
|
$self->app->log->error("error when showing captcha: $@"); |
|
|
|
$self->app->log->error("error when showing captcha: $@"); |
|
|
|
$self->res->code(500); |
|
|
|
$self->app->client_reply(500, "internal error"); |
|
|
|
$self->render(text => "internal error\n"); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -39,8 +38,7 @@ sub c_list { |
|
|
|
|
|
|
|
|
|
|
|
my $ref = $self->referrer; |
|
|
|
my $ref = $self->referrer; |
|
|
|
unless ($ref and ref($ref) eq 'HASH') { |
|
|
|
unless ($ref and ref($ref) eq 'HASH') { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "can't detect referred page"); |
|
|
|
$self->render(text => "can't detect referred page\n"); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -54,16 +52,14 @@ sub c_list { |
|
|
|
} |
|
|
|
} |
|
|
|
$self->render(json => \@cm); |
|
|
|
$self->render(json => \@cm); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "no such site"); |
|
|
|
$self->render(text => "no such site\n"); |
|
|
|
|
|
|
|
} 1; |
|
|
|
} 1; |
|
|
|
} or do { |
|
|
|
} or do { |
|
|
|
chomp $@; |
|
|
|
chomp $@; |
|
|
|
my $msg = sprintf "Error when listing comments for %s/%s: %s", |
|
|
|
my $msg = sprintf "Error when listing comments for %s/%s: %s", |
|
|
|
$ref->{site}, $ref->{pid}, $@; |
|
|
|
$ref->{site}, $ref->{pid}, $@; |
|
|
|
$self->app->log->error($msg); |
|
|
|
$self->app->log->error($msg); |
|
|
|
$self->res->code(500); |
|
|
|
$self->app->client_reply(500, "internal error"); |
|
|
|
$self->render(text => "internal error\n"); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -72,8 +68,7 @@ sub c_add { |
|
|
|
|
|
|
|
|
|
|
|
my $ref = $self->referrer; |
|
|
|
my $ref = $self->referrer; |
|
|
|
unless ($ref and ref($ref) eq 'HASH') { |
|
|
|
unless ($ref and ref($ref) eq 'HASH') { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "can't detect referred page"); |
|
|
|
$self->render(text => "can't detect referred page\n"); |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -88,31 +83,26 @@ sub c_add { |
|
|
|
} |
|
|
|
} |
|
|
|
do {{ |
|
|
|
do {{ |
|
|
|
unless ($msg{text}) { |
|
|
|
unless ($msg{text}) { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "empty message"); |
|
|
|
$self->render(text => "empty message\n"); |
|
|
|
|
|
|
|
last; |
|
|
|
last; |
|
|
|
} |
|
|
|
} |
|
|
|
my $sid = $self->app->sid_by_name($ref->{site}); |
|
|
|
my $sid = $self->app->sid_by_name($ref->{site}); |
|
|
|
unless ($sid) { |
|
|
|
unless ($sid) { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "no such site"); |
|
|
|
$self->render(text => "no such site\n"); |
|
|
|
|
|
|
|
last; |
|
|
|
last; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($cap{cid}) { |
|
|
|
if ($cap{cid}) { |
|
|
|
unless ($cap{code}) { |
|
|
|
unless ($cap{code}) { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "missing captcha code"); |
|
|
|
$self->render(text => "missing captcha code\n"); |
|
|
|
|
|
|
|
last; |
|
|
|
last; |
|
|
|
} |
|
|
|
} |
|
|
|
my $cap = $self->captcha_by_id($cap{cid}); |
|
|
|
my $cap = $self->captcha_by_id($cap{cid}); |
|
|
|
unless ($cap and $cap eq 'HASH') { |
|
|
|
unless ($cap and $cap eq 'HASH') { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "no captcha with this id"); |
|
|
|
$self->render(text => "no captcha with this id\n"); |
|
|
|
|
|
|
|
last; |
|
|
|
last; |
|
|
|
} |
|
|
|
} |
|
|
|
unless ($cap->{code} eq $cap{code}) { |
|
|
|
unless ($cap->{code} eq $cap{code}) { |
|
|
|
$self->res->code(400); |
|
|
|
$self->app->client_reply(400, "captcha code mismatch"); |
|
|
|
$self->render(text => "captcha code mismatch\n"); |
|
|
|
|
|
|
|
last; |
|
|
|
last; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -128,8 +118,7 @@ sub c_add { |
|
|
|
my $msg = sprintf "Error when listing comments for %s/%s: %s", |
|
|
|
my $msg = sprintf "Error when listing comments for %s/%s: %s", |
|
|
|
$ref->{site}, $ref->{pid}, $@; |
|
|
|
$ref->{site}, $ref->{pid}, $@; |
|
|
|
$self->app->log->error($msg); |
|
|
|
$self->app->log->error($msg); |
|
|
|
$self->res->code(500); |
|
|
|
$self->app->client_reply(500, "internal error"); |
|
|
|
$self->render(text => "internal error\n"); |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|