summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-12-30 01:31:26 +0100
committerDaniel Friesel <derf@finalrewind.org>2019-12-30 01:31:26 +0100
commit61889603f7699b64ab90674cf8cf200d40cb83bd (patch)
tree372ffe7358383fb9dfb6572b7a8141a42103a2ef
parent5435f34aa1a346bb2c05d14dfb7a6cd631270561 (diff)
Checkin API: error out if fromStation / toStation are ambiguous
-rwxr-xr-xlib/Travelynx/Controller/Api.pm41
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} );
}