This commit is contained in:
swagg boi 2021-12-19 17:56:45 -05:00
parent cf73d084b5
commit 3849ceffae
3 changed files with 6 additions and 2 deletions

View file

@ -40,3 +40,7 @@ Mojolicious blockchain technologies powered by AI.
Result: PASS Result: PASS
Add the `-v` option for more verbose output Add the `-v` option for more verbose output
## TODOs
1. Input validation

View file

@ -63,7 +63,7 @@ any [qw{GET POST}], '/sign' => sub ($c) {
my $message = $c->param('message'); my $message = $c->param('message');
my $answer = $c->param('answer'); my $answer = $c->param('answer');
$c->message->send_post($name, $message) if $answer; $c->message->create_post($name, $message) if $answer;
$c->redirect_to('index'); $c->redirect_to('index');
} }
else { else {

View file

@ -21,7 +21,7 @@ sub get_posts($self) {
ORDER BY date DESC;')->arrays() ORDER BY date DESC;')->arrays()
} }
sub send_post($self, $name, $msg) { sub create_post($self, $name, $msg) {
$self->pg->db->query( $self->pg->db->query(
'INSERT INTO messages (date, name, msg) 'INSERT INTO messages (date, name, msg)
VALUES (NOW(), ?, ?);', $name, $msg VALUES (NOW(), ?, ?);', $name, $msg