summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Travelynx/Controller/Api.pm12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm
index f31195a..9fe72b2 100755
--- a/lib/Travelynx/Controller/Api.pm
+++ b/lib/Travelynx/Controller/Api.pm
@@ -21,6 +21,9 @@ sub sanitize {
if ( not defined $value ) {
return undef;
}
+ if ( not defined $type ) {
+ return $value ? ( '' . $value ) : undef;
+ }
if ( $type eq '' ) {
return '' . $value;
}
@@ -184,8 +187,12 @@ sub travel_v1 {
my $from_station = sanitize( q{}, $payload->{fromStation} );
my $to_station = sanitize( q{}, $payload->{toStation} );
my $train_id;
+ my $dbris = sanitize( undef, $payload->{dbris} );
my $hafas = sanitize( undef, $payload->{hafas} );
- $hafas //= exists $payload->{train}{journeyID} ? 'DB' : undef;
+
+ if ( not $hafas and exists $payload->{train}{journeyID} ) {
+ $dbris //= 'bahn.de';
+ }
if (
not(
@@ -209,6 +216,7 @@ sub travel_v1 {
}
if ( not $hafas
+ and not $dbris
and not $self->stations->search( $from_station, backend_id => 1 ) )
{
$self->render(
@@ -225,6 +233,7 @@ sub travel_v1 {
if ( $to_station
and not $hafas
+ and not $dbris
and not $self->stations->search( $to_station, backend_id => 1 ) )
{
$self->render(
@@ -288,6 +297,7 @@ sub travel_v1 {
train_id => $train_id,
uid => $uid,
hafas => $hafas,
+ dbris => $dbris,
);
}
)->then(