From 4a95a107c5fa12a7e3953b0fa2579ec398ae66ee Mon Sep 17 00:00:00 2001 From: swag Date: Sat, 17 Jun 2023 18:22:19 -0400 Subject: [PATCH] Revert "Fix the 404 handling" This reverts commit 08cc1ba31f40512e4340f92f99d41f510f92edfc. --- lib/PostText/Controller/.#Thread.pm | 1 + lib/PostText/Controller/Remark.pm | 6 ------ lib/PostText/Controller/Thread.pm | 12 +----------- t/remark.t | 3 +-- t/thread.t | 10 ++++++---- templates/remark/flag.html.ep | 4 ++-- templates/thread/bump.html.ep | 4 ++-- templates/thread/flag.html.ep | 4 ++-- 8 files changed, 15 insertions(+), 29 deletions(-) create mode 120000 lib/PostText/Controller/.#Thread.pm diff --git a/lib/PostText/Controller/.#Thread.pm b/lib/PostText/Controller/.#Thread.pm new file mode 120000 index 0000000..b567959 --- /dev/null +++ b/lib/PostText/Controller/.#Thread.pm @@ -0,0 +1 @@ +daniel@graymember.5691 \ No newline at end of file diff --git a/lib/PostText/Controller/Remark.pm b/lib/PostText/Controller/Remark.pm index e248789..c640cc5 100644 --- a/lib/PostText/Controller/Remark.pm +++ b/lib/PostText/Controller/Remark.pm @@ -65,7 +65,6 @@ sub create($self) { sub flag($self) { my $remark_id = $self->param('remark_id'); - my $valid_id = $self->remark->by_id($remark_id) ? 1 : 0; my $v = $self->validation; $v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i); @@ -87,11 +86,6 @@ sub flag($self) { $self->stash(status => 400) } - $self->stash(status => 404, error => 'Remark not found 🤷') - unless $valid_id; - - $self->stash(valid_id => $valid_id); - return $self->render; } diff --git a/lib/PostText/Controller/Thread.pm b/lib/PostText/Controller/Thread.pm index 3a5ee75..ed707b4 100644 --- a/lib/PostText/Controller/Thread.pm +++ b/lib/PostText/Controller/Thread.pm @@ -140,7 +140,6 @@ sub feed($self) { sub bump($self) { my $thread_id = $self->param('thread_id'); - my $valid_id = $self->thread->by_id($thread_id) ? 1 : 0; my $v = $self->validation; $v->optional(captcha => 'trim')->size(4, 4)->like(qr/bump/i); @@ -158,17 +157,11 @@ sub bump($self) { $self->stash(status => 400) } - $self->stash(status => 404, error => 'Thread not found 🤷') - unless $valid_id; - - $self->stash(valid_id => $valid_id); - return $self->render; } sub flag($self) { my $thread_id = $self->param('thread_id'); - my $valid_id = $self->thread->by_id($thread_id) ? 1 : 0; my $v = $self->validation; $v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i); @@ -188,10 +181,7 @@ sub flag($self) { $self->stash(status => 400) } - $self->stash(status => 404, error => 'Thread not found 🤷') - unless $valid_id; - - $self->stash(valid_id => $valid_id); + $self->stash(thread_id => $thread_id); return $self->render; } diff --git a/t/remark.t b/t/remark.t index 20e2e04..b53a999 100644 --- a/t/remark.t +++ b/t/remark.t @@ -49,8 +49,7 @@ subtest 'Flagging remark', sub { ->text_like(h2 => qr/Remark #1/); $t->get_ok('/remark/flag/1' )->status_is(200); - $t->get_ok('/remark/flag/65536')->status_is(404) - ->text_like(p => qr/Remark not found/); + $t->get_ok('/remark/flag/65536')->status_is(404); $t->get_ok('/remark/flag/1', form => {captcha => 'flag'})->status_is(200); $t->get_ok('/remark/flag/1', form => {captcha => 'aaaa'})->status_is(400); }; diff --git a/t/thread.t b/t/thread.t index 07a8d9d..0a84906 100644 --- a/t/thread.t +++ b/t/thread.t @@ -84,9 +84,12 @@ subtest 'Bumping thread', sub { ->element_exists('a[href*="bump"]') ->text_like(h2 => qr/Thread #1/); + $t->get_ok('/thread/bump/1')->status_is(200) + ->element_exists('p[class="stash-with-info"]') + ->text_like(p => qr/Thread #1 has been bumped/); + $t->get_ok('/thread/bump/1' )->status_is(200); - $t->get_ok('/thread/bump/65536')->status_is(404) - ->text_like(p => qr/Thread not found/); + $t->get_ok('/thread/bump/65536')->status_is(404); $t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(200); $t->get_ok('/thread/bump/1', form => {captcha => 'aaaa'})->status_is(400); }; @@ -101,8 +104,7 @@ subtest 'Flagging thread', sub { ->text_like(h2 => qr/Thread #1/); $t->get_ok('/thread/flag/1' )->status_is(200); - $t->get_ok('/thread/flag/65536')->status_is(404) - ->text_like(p => qr/Thread not found/); + $t->get_ok('/thread/flag/65536')->status_is(404); $t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(200); $t->get_ok('/thread/flag/1', form => {captcha => 'aaaa'})->status_is(400); }; diff --git a/templates/remark/flag.html.ep b/templates/remark/flag.html.ep index 7d17ae0..fdbd601 100644 --- a/templates/remark/flag.html.ep +++ b/templates/remark/flag.html.ep @@ -1,7 +1,7 @@ % layout 'default'; -% title $valid_id ? "Flag Remark #$remark_id" : '?'; +% title $remark_id ? "Flag Remark #$remark_id" : '?';

<%= title %>

-<% if ($valid_id) { =%> +<% if ($remark_id) { =%>
<% if (my $error = validation->error('captcha')) { =%> diff --git a/templates/thread/bump.html.ep b/templates/thread/bump.html.ep index fae0924..1b9d77e 100644 --- a/templates/thread/bump.html.ep +++ b/templates/thread/bump.html.ep @@ -1,7 +1,7 @@ % layout 'default'; -% title $valid_id ? "Bump Thread #$thread_id" : '?'; +% title $thread_id ? "Bump Thread #$thread_id" : '?';

<%= title %>

-<% if ($valid_id) { =%> +<% if ($thread_id) { =%>
<% if (my $error = validation->error('captcha')) { =%> diff --git a/templates/thread/flag.html.ep b/templates/thread/flag.html.ep index 77450cc..65a0296 100644 --- a/templates/thread/flag.html.ep +++ b/templates/thread/flag.html.ep @@ -1,7 +1,7 @@ % layout 'default'; -% title $valid_id ? "Flag Thread #$thread_id" : '?'; +% title $thread_id ? "Flag Thread #$thread_id" : '?';

<%= title %>

-<% if ($valid_id) { =%> +<% if ($thread_id) { =%>
<% if (my $error = validation->error('captcha')) { =%>