Skip to content
Snippets Groups Projects
Verified Commit 4b3b035b authored by Andrej Ramašeuski's avatar Andrej Ramašeuski
Browse files

Smazani postu

parent e85b66fa
No related branches found
No related tags found
No related merge requests found
......@@ -32,12 +32,6 @@ sub create ($c) {
my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg);
# TODO: vyhodit
$pubsub->json('posts')->notify( posts => {
event => 'created',
payload => $post->view->format(),
});
$pubsub->json('notify')->notify( notify => {
event => 'post_created',
payload => $post->view->format(),
......@@ -81,6 +75,8 @@ sub list ($c) {
my ($cond, $attrs) = $c->search_parametrs( $args );
$cond->{deleted} = undef;
# Vzdy jen k jednemu programovemu bodu - parametr nebo aktualni
if ( $args->{program_entry_id} ) {
$cond->{program_entry_id} = $args->{program_entry_id};
......@@ -192,6 +188,28 @@ sub update ($c) {
$c->render(status => 204, text => '');
}
sub delete ($c) {
$c->openapi->valid_input or return;
my $post = $c->schema->resultset('Post')->find($c->stash->{id});
return $c->error(404, 'Post not found') if ! $post;
my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg);
my $guard = $c->schema->txn_scope_guard;
$post->update({ deleted => \'now()', });
$pubsub->json('notify')->notify( notify => {
event => 'post_deleted',
payload => {
id => $post->id,
}
});
$guard->commit;
$c->render(status => 204, text => '');
}
sub ranking ($c) {
$c->openapi->valid_input or return;
my $args = $c->validation->output;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment