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

Optimalizace. Pridana metoda 'info'

parent e5ac34c0
Branches
Tags
No related merge requests found
......@@ -24,22 +24,22 @@ sub list {
STREAM:
while ( my $stream = $streams->next()) {
my $rights = $c->session->{user}{acl}{ $stream->key };
next STREAM if ! $rights;
push @streams, {
my $rights = $c->session->{user}{acl}{ $stream->key } || next STREAM;
my %stream = (
$stream->get_columns(),
is_live => $stream->is_live,
key => $stream->key,
name => $stream->name,
publisher => $stream->is_live ? $stream->publish_user_name : '',
is_writeable => $c->is('publisher')
&& $stream->is_writeable( $rights ),
is_recordable => $c->is('publisher')
&& $stream->is_recordable( $c->session->{user}{username} ),
};
is_writeable => $stream->is_writeable( $rights ),
is_recordable => $stream->is_recordable( $c->session->{user}{username} ),
);
delete $stream{publish_user_name} if ! $stream->is_live;
push @streams, \%stream;
}
$c->stash->{streams} = \@streams;
$c->render( json => \@streams );
}
......@@ -61,16 +61,54 @@ sub player {
return;
}
$c->stash->{stream} = $stream;
$c->stash->{stream} = {
$stream->get_columns,
is_live => $stream->is_live,
};
if ( ! ( $c->session->{user}{acl}{ $stream->key } & 4 ) ) { # TODO:constant
$c->render('stream/403');
return;
}
$c->render();
}
sub info {
my $c = shift;
# vzdy aktualizovat
$c->session->{user}{acl} = $c->schema->resultset('ACL')->user_acl(
$c->session->{user}
);
# stream
my $stream = $c->schema->resultset('Stream_view')->find({
id => $c->stash->{id}
});
if ( ! $stream ) {
$c->render('stream/404');
return;
}
my $rights = $c->session->{user}{acl}{ $stream->key };
if ( ! $rights ) {
$c->render('stream/403');
return;
}
$c->stash->{stream} = {
$stream->get_columns(),
is_live => $stream->is_live,
is_writeable => $stream->is_writeable( $rights ),
is_recordable => $stream->is_recordable( $c->session->{user}{username} ),
};
$c->render();
}
1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment