diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-09-04 18:38:35 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-09-04 18:38:35 +0200 |
commit | 7eb5f967f2d85ea3a7846353fbaf666e3a0e2bc5 (patch) | |
tree | 5072bd80f44589de6781a640d5d564f035c4ef33 /lib/Travelynx | |
parent | 482fa975b5f50064deb57b651019908c17b71f47 (diff) |
profile: limit history to four weeks by default
Diffstat (limited to 'lib/Travelynx')
-rw-r--r-- | lib/Travelynx/Controller/Account.pm | 9 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 34 |
2 files changed, 41 insertions, 2 deletions
diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index 10200a6..c68a22c 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -261,6 +261,13 @@ sub privacy { $public_level &= ~0x30; } + if ( $self->param('history_age') eq 'infinite' ) { + $public_level |= 0x40; + } + else { + $public_level &= ~0x40; + } + $self->users->set_privacy( uid => $user->{id}, level => $public_level @@ -281,6 +288,8 @@ sub privacy { : $public_level & 0x20 ? 'extern' : 'private' ); + $self->param( + history_age => $public_level & 0x40 ? 'infinite' : 'month' ); $self->render( 'privacy', name => $user->{name} ); } } diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index 33b3118..24edaa3 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -160,12 +160,32 @@ sub public_profile { ) { my $status = $self->get_user_status( $user->{id} ); + my @journeys; + if ( $user->{public_level} & 0x40 ) { + @journeys = $self->journeys->get( + uid => $user->{id}, + limit => 10, + with_datetime => 1 + ); + } + else { + my $now = DateTime->now( time_zone => 'Europe/Berlin' ); + my $month_ago = $now->clone->subtract( weeks => 4 ); + @journeys = $self->journeys->get( + uid => $user->{id}, + limit => 10, + with_datetime => 1, + after => $month_ago, + before => $now + ); + } $self->render( 'profile', name => $name, uid => $user->{id}, public_level => $user->{public_level}, journey => $status, + journeys => [@journeys], version => $self->app->config->{version} // 'UNKNOWN', ); } @@ -207,12 +227,22 @@ sub public_journey_details { with_polyline => 1, ); + if ( not( $user->{public_level} & 0x40 ) ) { + my $month_ago = DateTime->now( time_zone => 'Europe/Berlin' ) + ->subtract( weeks => 4 )->epoch; + if ( $journey and $journey->{rt_dep_ts} < $month_ago ) { + $journey = undef; + } + } + if ($journey) { my $map_data = $self->journeys_to_map_data( journeys => [$journey], include_manual => 1, ); - if ( $journey->{user_data}{comment} ) { + if ( $journey->{user_data}{comment} + and not $user->{public_level} & 0x04 ) + { delete $journey->{user_data}{comment}; } $self->render( @@ -226,7 +256,7 @@ sub public_journey_details { ); } else { - $self->render( 'not_found', ); + $self->render('not_found'); } } else { |