Restructured some things to make it simpler and easier to read

This commit is contained in:
swagg boi 2022-10-22 14:09:31 -04:00
parent db2f835adf
commit f51af35605
2 changed files with 12 additions and 8 deletions

View file

@ -19,16 +19,18 @@ sub create($self) {
$v = $self->validation if $self->req->method eq 'POST'; $v = $self->validation if $self->req->method eq 'POST';
if ($v && $v->has_data) { if ($v && $v->has_data) {
my $remark_author = $self->param('author'); my ($remark_author, $remark_body);
my $remark_body = $self->param('body' );
$v->required('author')->size(1, 63 ); $v->required('author')->size(1, 63);
$v->required('body' )->size(2, 4000); $v->required('body' )->size(2, 4000);
if ($v->has_error) { if ($v->has_error) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
$remark_author = $v->param('author');
$remark_body = $v->param('body' );
$self->remark->create( $self->remark->create(
$thread_id, $thread_id,
$remark_author, $remark_author,

View file

@ -8,18 +8,20 @@ sub create($self) {
$v = $self->validation if $self->req->method eq 'POST'; $v = $self->validation if $self->req->method eq 'POST';
if ($v && $v->has_data) { if ($v && $v->has_data) {
my $thread_author = $self->param('author'); my ($thread_author, $thread_title, $thread_body);
my $thread_title = $self->param('title' );
my $thread_body = $self->param('body' );
$v->required('author')->size(1, 63 ); $v->required('author')->size(1, 63);
$v->required('title' )->size(1, 127 ); $v->required('title' )->size(1, 127);
$v->required('body' )->size(2, 4000); $v->required('body' )->size(2, 4000);
if ($v->has_error) { if ($v->has_error) {
$self->stash(status => 400) $self->stash(status => 400)
} }
else { else {
$thread_author = $v->param('author');
$thread_title = $v->param('title' );
$thread_body = $v->param('body' );
my $new_thread_id = $self->thread->create( my $new_thread_id = $self->thread->create(
$thread_author, $thread_author,
$thread_title, $thread_title,