diff options
author | Daniel Friesel <derf@finalrewind.org> | 2019-12-30 01:31:26 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2019-12-30 01:31:26 +0100 |
commit | 61889603f7699b64ab90674cf8cf200d40cb83bd (patch) | |
tree | 372ffe7358383fb9dfb6572b7a8141a42103a2ef /lib/Travelynx | |
parent | 5435f34aa1a346bb2c05d14dfb7a6cd631270561 (diff) |
Checkin API: error out if fromStation / toStation are ambiguous
Diffstat (limited to 'lib/Travelynx')
-rwxr-xr-x | lib/Travelynx/Controller/Api.pm | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 4546292..b951af4 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -185,6 +185,47 @@ sub travel_v1 { return; } + if ( + @{ + [ + Travel::Status::DE::IRIS::Stations::get_station( + $from_station) + ] + } != 1 + ) + { + $self->render( + json => { + success => \0, + deprecated => \0, + error => 'fromStation is ambiguous', + status => $self->get_user_status_json_v1($uid) + }, + ); + return; + } + + if ( + $to_station + and @{ + [ + Travel::Status::DE::IRIS::Stations::get_station( + $to_station) + ] + } != 1 + ) + { + $self->render( + json => { + success => \0, + deprecated => \0, + error => 'toStation is ambiguous', + status => $self->get_user_status_json_v1($uid) + }, + ); + return; + } + if ( exists $payload->{train}{id} ) { $train_id = sanitize( 0, $payload->{train}{id} ); } |