From 11d2f80524d03a1c4e261e7cb5a3f13b370de491 Mon Sep 17 00:00:00 2001 From: swag Date: Sat, 17 Jun 2023 18:24:55 -0400 Subject: [PATCH] Revert "Add CAPTCHA for flag_thread" This reverts commit ce6d405b1dc5b0caf75b58551405a01264c7265c. --- lib/PostText/Controller/Thread.pm | 28 +++++++--------------------- t/thread.t | 5 +++-- templates/thread/flag.html.ep | 17 ----------------- 3 files changed, 10 insertions(+), 40 deletions(-) delete mode 100644 templates/thread/flag.html.ep diff --git a/lib/PostText/Controller/Thread.pm b/lib/PostText/Controller/Thread.pm index 780a5b7..2f0e9a2 100644 --- a/lib/PostText/Controller/Thread.pm +++ b/lib/PostText/Controller/Thread.pm @@ -150,29 +150,15 @@ sub bump($self) { } sub flag($self) { - my $thread_id = $self->param('thread_id'); - my $v = $self->validation; + my $thread_id = $self->param('thread_id'); + my $redirect_url = $self->url_for('threads_list')->fragment('info')->to_abs; - $v->optional(captcha => 'trim')->size(4, 4)->like(qr/flag/i); + $self->thread->flag($thread_id); + $self->flash( + info => "Thread #$thread_id has been flagged for moderator. 🚩" + ); - if ($v->is_valid) { - my $redirect_url = - $self->url_for('threads_list')->fragment('info')->to_abs; - - $self->thread->flag($thread_id); - $self->flash( - info => "Thread #$thread_id has been flagged for moderator. 🚩" - ); - - return $self->redirect_to($redirect_url); - } - elsif ($v->has_error) { - $self->stash(status => 400) - } - - $self->stash(thread_id => $thread_id); - - return $self->render; + $self->redirect_to($redirect_url); } 1; diff --git a/t/thread.t b/t/thread.t index 843ce41..da9e6ff 100644 --- a/t/thread.t +++ b/t/thread.t @@ -98,8 +98,9 @@ subtest 'Flagging thread', sub { ->element_exists('a[href*="flag"]') ->text_like(h2 => qr/Thread #1/); - $t->get_ok('/thread/flag/1' )->status_is(200); - $t->get_ok('/thread/flag/65536')->status_is(404); + $t->get_ok('/thread/flag/1')->status_is(200) + ->element_exists('p[class="stash-with-info"]') + ->text_like(p => qr/Thread #1 has been flagged/); }; done_testing; diff --git a/templates/thread/flag.html.ep b/templates/thread/flag.html.ep deleted file mode 100644 index 8c84e3a..0000000 --- a/templates/thread/flag.html.ep +++ /dev/null @@ -1,17 +0,0 @@ -% layout 'default'; -% title $thread_id ? "Flag 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 'flag' to confirm:" %> - <%= text_field captcha => id => 'captcha' %> -
- - -
-<% } =%>