From 5461326f01f6b043f2dd0470788e03fd68790e5e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 4 Mar 2023 13:22:13 +0100 Subject: always show /p/user if /status/user exists; only limit past journeys --- lib/Travelynx/Controller/Traveling.pm | 68 ++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'lib/Travelynx/Controller/Traveling.pm') diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index a3274aa..1580bb6 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -638,10 +638,7 @@ sub public_profile { my $name = $self->stash('name'); my $user = $self->users->get_privacy_by_name( name => $name ); - if ( not $user - or $user->{past_visible} == 0 - or ( $user->{past_visible} == 1 and not $self->is_user_authenticated ) ) - { + if ( not $user ) { $self->render('not_found'); return; } @@ -677,38 +674,45 @@ sub public_profile { $status->{arr_name} = undef; } - my %opt = ( - uid => $user->{id}, - limit => 10, - with_datetime => 1 - ); - - if ( not $user->{past_all} ) { - my $now = DateTime->now( time_zone => 'Europe/Berlin' ); - $opt{before} = DateTime->now( time_zone => 'Europe/Berlin' ); - $opt{after} = $now->clone->subtract( weeks => 4 ); - } + my @journeys; - if ( - $user->{default_visibility_str} eq 'public' - or ( $user->{default_visibility_str} eq 'travelynx' - and $self->is_user_authenticated ) - ) + if ( $user->{past_visible} == 2 + or ( $user->{past_visible} == 1 and $self->is_user_authenticated ) ) { - $opt{with_default_visibility} = 1; - } - else { - $opt{with_default_visibility} = 0; - } - if ( $self->is_user_authenticated ) { - $opt{min_visibility} = 'travelynx'; - } - else { - $opt{min_visibility} = 'public'; - } + my %opt = ( + uid => $user->{id}, + limit => 10, + with_datetime => 1 + ); + + if ( not $user->{past_all} ) { + my $now = DateTime->now( time_zone => 'Europe/Berlin' ); + $opt{before} = DateTime->now( time_zone => 'Europe/Berlin' ); + $opt{after} = $now->clone->subtract( weeks => 4 ); + } - my @journeys = $self->journeys->get(%opt); + if ( + $user->{default_visibility_str} eq 'public' + or ( $user->{default_visibility_str} eq 'travelynx' + and $self->is_user_authenticated ) + ) + { + $opt{with_default_visibility} = 1; + } + else { + $opt{with_default_visibility} = 0; + } + + if ( $self->is_user_authenticated ) { + $opt{min_visibility} = 'travelynx'; + } + else { + $opt{min_visibility} = 'public'; + } + + @journeys = $self->journeys->get(%opt); + } $self->render( 'profile', -- cgit v1.2.3