diff options
author | Derf Null <derf@finalrewind.org> | 2023-05-21 19:44:43 +0200 |
---|---|---|
committer | Derf Null <derf@finalrewind.org> | 2023-05-21 19:44:43 +0200 |
commit | dbc5c38968a11ac17dc99723bc8866de9f739c28 (patch) | |
tree | 63978b9e129174c2605677d662907bdacc474e60 | |
parent | 2e10115072b8ef90c9f08662ef18619e66899f4a (diff) |
get_user_status_json_v1: add public flag to hide actionTime
-rwxr-xr-x | lib/Travelynx.pm | 17 | ||||
-rwxr-xr-x | lib/Travelynx/Controller/Api.pm | 28 |
2 files changed, 24 insertions, 21 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index c594e96..643024b 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -836,7 +836,7 @@ sub startup { return; } - my $status = $self->get_user_status_json_v1($uid); + my $status = $self->get_user_status_json_v1( uid => $uid ); my $header = {}; my $hook_body = { reason => $reason, @@ -1694,11 +1694,10 @@ sub startup { $self->helper( 'get_user_status_json_v1' => sub { - my ( $self, $uid ) = @_; + my ( $self, %opt ) = @_; + my $uid = $opt{uid}; my $status = $self->get_user_status($uid); - # TODO simplify lon/lat (can be returned from get_user_status) - my $ret = { deprecated => \0, checkedIn => ( @@ -1737,12 +1736,16 @@ sub startup { no => $status->{train_no}, id => $status->{train_id}, }, - actionTime => $status->{timestamp} - ? $status->{timestamp}->epoch - : undef, intermediateStops => [], }; + if ( not $opt{public} ) { + $ret->{actionTime} + = $status->{timestamp} + ? $status->{timestamp}->epoch + : undef; + } + for my $stop ( @{ $status->{route_after} // [] } ) { if ( $status->{arr_name} and $stop->[0] eq $status->{arr_name} ) { diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 0f92c84..0410fc6 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -93,7 +93,7 @@ sub get_v1 { return; } if ( $api_action eq 'status' ) { - $self->render( json => $self->get_user_status_json_v1($uid) ); + $self->render( json => $self->get_user_status_json_v1( uid => $uid ) ); } else { $self->render( @@ -166,7 +166,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Missing or invalid action', - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) }, ); return; @@ -190,7 +190,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Missing fromStation or train data', - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) }, ); return; @@ -202,7 +202,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Unknown fromStation', - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) }, ); return; @@ -214,7 +214,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Unknown toStation', - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) }, ); return; @@ -238,7 +238,7 @@ sub travel_v1 { error => 'Error requesting departures from fromStation: ' . $status->{errstr}, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); return; @@ -253,7 +253,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Train not found at fromStation', - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); return; @@ -285,7 +285,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Checkin/Checkout error: ' . $error, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); } @@ -294,7 +294,7 @@ sub travel_v1 { json => { success => \1, deprecated => \0, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); } @@ -308,7 +308,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Missing toStation', - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) }, ); return; @@ -332,7 +332,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => 'Checkout error: ' . $error, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); } @@ -341,7 +341,7 @@ sub travel_v1 { json => { success => \1, deprecated => \0, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); } @@ -354,7 +354,7 @@ sub travel_v1 { success => \0, deprecated => \0, error => $error, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); } @@ -363,7 +363,7 @@ sub travel_v1 { json => { success => \1, deprecated => \0, - status => $self->get_user_status_json_v1($uid) + status => $self->get_user_status_json_v1( uid => $uid ) } ); } |