From 9ae401f86d91de1dd79efcdb36d64e2a813c1d8c Mon Sep 17 00:00:00 2001 From: swag Date: Sat, 17 Jun 2023 18:22:22 -0400 Subject: [PATCH] Revert "Confirmation for bump_thread" This reverts commit f4c9d251393f69434dca26c0024eb4071d976fd2. --- lib/PostText/Controller/Thread.pm | 21 +++++---------------- t/thread.t | 5 ----- templates/thread/bump.html.ep | 17 ----------------- templates/thread/flag.html.ep | 2 +- 4 files changed, 6 insertions(+), 39 deletions(-) delete mode 100644 templates/thread/bump.html.ep diff --git a/lib/PostText/Controller/Thread.pm b/lib/PostText/Controller/Thread.pm index 61b0db7..780a5b7 100644 --- a/lib/PostText/Controller/Thread.pm +++ b/lib/PostText/Controller/Thread.pm @@ -140,24 +140,13 @@ sub feed($self) { sub bump($self) { my $thread_id = $self->param('thread_id'); - my $v = $self->validation; - $v->optional(captcha => 'trim')->size(4, 4)->like(qr/bump/i); + $self->thread->bump($thread_id); + $self->flash(info => "Thread #$thread_id has been bumped. 🔝"); - if ($v->is_valid) { - my $redirect_url = - $self->url_for('threads_list')->fragment('info')->to_abs; - - $self->thread->bump($thread_id); - $self->flash(info => "Thread #$thread_id has been bumped. 🔝"); - - return $self->redirect_to($redirect_url); - } - elsif ($v->has_error) { - $self->stash(status => 400) - } - - $self->render; + $self->redirect_to( + $self->url_for('threads_list')->fragment('info')->to_abs + ); } sub flag($self) { diff --git a/t/thread.t b/t/thread.t index 844bc6c..843ce41 100644 --- a/t/thread.t +++ b/t/thread.t @@ -87,10 +87,6 @@ subtest 'Bumping thread', sub { $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); - $t->get_ok('/thread/bump/1', form => {captcha => 'bump'})->status_is(400); }; subtest 'Flagging thread', sub { @@ -104,7 +100,6 @@ subtest 'Flagging thread', sub { $t->get_ok('/thread/flag/1' )->status_is(200); $t->get_ok('/thread/flag/65536')->status_is(404); - $t->get_ok('/thread/flag/1', form => {captcha => 'flag'})->status_is(400); }; done_testing; diff --git a/templates/thread/bump.html.ep b/templates/thread/bump.html.ep deleted file mode 100644 index 1b9d77e..0000000 --- a/templates/thread/bump.html.ep +++ /dev/null @@ -1,17 +0,0 @@ -% layout 'default'; -% title $thread_id ? "Bump Thread #$thread_id" : '?'; -

<%= title %>

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

Must be between <%= $error->[2] %> - and <%= $error->[3] %> characters.

- <% } =%> - <%= label_for captcha => "Enter the word 'bump' to confirm:" %> - <%= text_field captcha => id => 'captcha' %> -
- - -
-<% } =%> diff --git a/templates/thread/flag.html.ep b/templates/thread/flag.html.ep index 65a0296..8c84e3a 100644 --- a/templates/thread/flag.html.ep +++ b/templates/thread/flag.html.ep @@ -11,7 +11,7 @@ <%= label_for captcha => "Enter the word 'flag' to confirm:" %> <%= text_field captcha => id => 'captcha' %> - + <% } =%>