package PiTube::Schema::Result::Stream_view;

use strict;
use warnings;

use base 'PiTube::Schema::Result::Stream';

our $VERSION = 1;

__PACKAGE__->table('streams_view');

__PACKAGE__->add_columns(qw(
   publish_last_age
   publish_user_name
));

sub is_writeable {
    my $self  = shift;
    my $acl   = shift // 0;

    return $acl & 2;
}

sub is_recordable {
    my $self    = shift;
    my $user_id = shift // 0;

    return 0 if ! $self->is_live;
    return $user_id == $self->publish_user_id;
}

1;