Fix CAPTCHA and flash error for spam

This commit is contained in:
swagg boi 2022-01-02 17:53:43 -05:00
parent 837304d565
commit 13e89cdfa1
2 changed files with 8 additions and 6 deletions

View file

@ -68,14 +68,15 @@ any [qw{GET POST}], '/sign' => sub ($c) {
my $name = $c->param('name') || 'Anonymous';
my $url = $c->param('url');
my $message = $c->param('message');
my $spam = $c->param('answer') ? 0 : 1;
# No URLs in message body since they have their own field
$spam =
$message =~ /$RE{URI}{HTTP}{-scheme => qr<https?>}/ ? 1 : 0;
my $spam =
!$c->param('answer') ? 1 :
$message =~ /$RE{URI}{HTTP}{-scheme => qr<https?>}/ ? 1 :
0;
if ($message) {
$c->message->create_post($name, $message, $url, $spam);
$c->flash(error => 'This message was flagged as spam') if $spam;
$c->redirect_to('index');
}
else {

View file

@ -16,7 +16,8 @@
<div class="error">
<h2>Stop! You've violated the law:</h2>
<p><%= flash 'error' %></p>
<p>This incident has been reported to the cyber-police.</p>
<p>Please report to the
<%= link_to 'cyber police', 'mailto:swaggboi@slackware.uk' %>!</p>
</div>
<% } =%>
<hr>