my $dbh = $c->model;
$c->forward('findThread');
- $thread = $c->stash->{thread};
+ $c->forward('findPosts') if $c->stash->{thread};
+ $c->forward('markThreadAsRead') if $c->user_exists;
+}
+
+sub findPosts :Private {
+ my ( $self, $c, $thread ) = @_;
+ my $dbh = $c->model;
my $posts = $dbh->prepare(q{
SELECT u.username,date_trunc('seconds',fp.time::timestamp) AS time
WHERE ft.ftid = $1
ORDER BY fp.time ASC
});
- $posts->execute($c->stash->{thread}->{ftid},$c->stash->{UID});
+ $posts->execute($thread,$c->stash->{UID});
my @posts;
while (my $post = $posts->fetchrow_hashref){
}
$c->stash(posts => \@posts);
- $c->forward('markThreadAsRead') if $c->user_exists;
}