summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller/Traveling.pm
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-03 22:27:50 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-03 22:27:50 +0200
commit482fa975b5f50064deb57b651019908c17b71f47 (patch)
tree118e0247f29c058f61e53db5716df1c1d848d898 /lib/Travelynx/Controller/Traveling.pm
parentea0fe3ea3e72eb690dd5a92eb4831523be740d08 (diff)
add public profile page and public journey details
Diffstat (limited to 'lib/Travelynx/Controller/Traveling.pm')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm88
1 files changed, 88 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 59bad45..33b3118 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -146,6 +146,94 @@ sub user_status {
}
}
+sub public_profile {
+ my ($self) = @_;
+
+ my $name = $self->stash('name');
+ my $user = $self->users->get_privacy_by_name( name => $name );
+
+ if (
+ $user
+ and ( $user->{public_level} & 0x22
+ or
+ ( $user->{public_level} & 0x11 and $self->is_user_authenticated ) )
+ )
+ {
+ my $status = $self->get_user_status( $user->{id} );
+ $self->render(
+ 'profile',
+ name => $name,
+ uid => $user->{id},
+ public_level => $user->{public_level},
+ journey => $status,
+ version => $self->app->config->{version} // 'UNKNOWN',
+ );
+ }
+ else {
+ $self->render('not_found');
+ }
+}
+
+sub public_journey_details {
+ my ($self) = @_;
+ my $name = $self->stash('name');
+ my $journey_id = $self->stash('id');
+ my $user = $self->users->get_privacy_by_name( name => $name );
+
+ $self->param( journey_id => $journey_id );
+
+ if ( not( $journey_id and $journey_id =~ m{ ^ \d+ $ }x ) ) {
+ $self->render(
+ 'journey',
+ status => 404,
+ error => 'notfound',
+ journey => {}
+ );
+ return;
+ }
+
+ if (
+ $user
+ and ( $user->{public_level} & 0x20
+ or
+ ( $user->{public_level} & 0x10 and $self->is_user_authenticated ) )
+ )
+ {
+ my $journey = $self->journeys->get_single(
+ uid => $user->{id},
+ journey_id => $journey_id,
+ verbose => 1,
+ with_datetime => 1,
+ with_polyline => 1,
+ );
+
+ if ($journey) {
+ my $map_data = $self->journeys_to_map_data(
+ journeys => [$journey],
+ include_manual => 1,
+ );
+ if ( $journey->{user_data}{comment} ) {
+ delete $journey->{user_data}{comment};
+ }
+ $self->render(
+ 'journey',
+ error => undef,
+ journey => $journey,
+ with_map => 1,
+ username => $name,
+ readonly => 1,
+ %{$map_data},
+ );
+ }
+ else {
+ $self->render( 'not_found', );
+ }
+ }
+ else {
+ $self->render('not_found');
+ }
+}
+
sub public_status_card {
my ($self) = @_;