rename get_privacy_by_name to get_privacy_by, allow requests by uid
This commit is contained in:
parent
68468379e5
commit
ac816c09b2
3 changed files with 18 additions and 16 deletions
|
@ -994,7 +994,7 @@ sub webfinger {
|
||||||
}
|
}
|
||||||
|
|
||||||
my $name = $+{name};
|
my $name = $+{name};
|
||||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
my $user = $self->users->get_privacy_by( name => $name );
|
||||||
|
|
||||||
if ( not $user ) {
|
if ( not $user ) {
|
||||||
$self->render( 'not_found', status => 404 );
|
$self->render( 'not_found', status => 404 );
|
||||||
|
|
|
@ -63,7 +63,7 @@ sub profile {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my $name = $self->stash('name');
|
my $name = $self->stash('name');
|
||||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
my $user = $self->users->get_privacy_by( name => $name );
|
||||||
|
|
||||||
if ( not $user ) {
|
if ( not $user ) {
|
||||||
$self->render('not_found');
|
$self->render('not_found');
|
||||||
|
@ -157,7 +157,7 @@ sub journey_details {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $name = $self->stash('name');
|
my $name = $self->stash('name');
|
||||||
my $journey_id = $self->stash('id');
|
my $journey_id = $self->stash('id');
|
||||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
my $user = $self->users->get_privacy_by( name => $name );
|
||||||
|
|
||||||
$self->param( journey_id => $journey_id );
|
$self->param( journey_id => $journey_id );
|
||||||
|
|
||||||
|
@ -290,7 +290,7 @@ sub user_status {
|
||||||
|
|
||||||
my $name = $self->stash('name');
|
my $name = $self->stash('name');
|
||||||
my $ts = $self->stash('ts') // 0;
|
my $ts = $self->stash('ts') // 0;
|
||||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
my $user = $self->users->get_privacy_by( name => $name );
|
||||||
|
|
||||||
if ( not $user ) {
|
if ( not $user ) {
|
||||||
$self->render('not_found');
|
$self->render('not_found');
|
||||||
|
@ -434,7 +434,7 @@ sub status_card {
|
||||||
|
|
||||||
my $name = $self->stash('name');
|
my $name = $self->stash('name');
|
||||||
$name =~ s{[.]html$}{};
|
$name =~ s{[.]html$}{};
|
||||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
my $user = $self->users->get_privacy_by( name => $name );
|
||||||
|
|
||||||
delete $self->stash->{layout};
|
delete $self->stash->{layout};
|
||||||
|
|
||||||
|
|
|
@ -154,19 +154,21 @@ sub get_uid_by_name_and_mail {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_privacy_by_name {
|
sub get_privacy_by {
|
||||||
my ( $self, %opt ) = @_;
|
my ( $self, %opt ) = @_;
|
||||||
my $db = $opt{db} // $self->{pg}->db;
|
my $db = $opt{db} // $self->{pg}->db;
|
||||||
my $name = $opt{name};
|
|
||||||
|
|
||||||
my $res = $db->select(
|
my %where;
|
||||||
'users',
|
|
||||||
[ 'id', 'public_level' ],
|
if ( $opt{name} ) {
|
||||||
{
|
$where{name} = $opt{name};
|
||||||
name => $name,
|
}
|
||||||
status => 1
|
else {
|
||||||
}
|
$where{id} = $opt{uid};
|
||||||
);
|
}
|
||||||
|
|
||||||
|
my $res = $db->select( 'users', [ 'id', 'public_level' ],
|
||||||
|
{ %where, status => 1 } );
|
||||||
|
|
||||||
if ( my $user = $res->hash ) {
|
if ( my $user = $res->hash ) {
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue