Clean up some stuff

This commit is contained in:
swagg boi 2022-07-22 11:06:29 -04:00
parent 32fb9d0268
commit 246001b242
2 changed files with 4 additions and 7 deletions

View file

@ -85,15 +85,16 @@ any [qw{GET POST}], '/sign' => sub ($c) {
$c->stash(status => 400) $c->stash(status => 400)
} }
else { else {
my $new_message_id = $c->message->create_post($name, $message, $url, $spam);
$c->message->create_post($name, $message, $url, $spam);
if ($spam) { if ($spam) {
$c->flash(error => 'This message was flagged as spam') $c->flash(error => 'This message was flagged as spam')
} }
# Send this notification if there's a Webhook URL # Send this notification if there's a Webhook URL
elsif (app->mode() eq 'production' && -s '.tom.url') { elsif (app->mode() eq 'production' && -s '.tom.url') {
my ($url_file, $url, $webhook); my ($new_message_id, $url_file, $url, $webhook);
$new_message_id = $c->message->get_last_message_id();
open($url_file, '.tom.url') || die "$@"; open($url_file, '.tom.url') || die "$@";
chomp($url = <$url_file>); chomp($url = <$url_file>);

View file

@ -76,8 +76,6 @@ sub get_spam($self, $this_page = undef) {
} }
sub create_post($self, $name, $message, $url = undef, $spam = 1) { sub create_post($self, $name, $message, $url = undef, $spam = 1) {
my $message_id = $self->get_last_message_id();
if ($url) { if ($url) {
$self->pg->db->query(<<~'END_SQL', $name, $message, $url, $spam) $self->pg->db->query(<<~'END_SQL', $name, $message, $url, $spam)
INSERT INTO messages (visitor_name, message, homepage_url, is_spam) INSERT INTO messages (visitor_name, message, homepage_url, is_spam)
@ -90,8 +88,6 @@ sub create_post($self, $name, $message, $url = undef, $spam = 1) {
VALUES (?, ?, ?); VALUES (?, ?, ?);
END_SQL END_SQL
} }
++$message_id;
} }
sub max_posts($self, $value = undef) { sub max_posts($self, $value = undef) {