From ae21896982b5f53c0a011740f58a97be40bf0b30 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 17 Dec 2019 20:01:39 +0100 Subject: API: Add lax option --- lib/Travelynx.pm | 9 +++++++-- lib/Travelynx/Controller/Api.pm | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 81dae20..5c54322 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -958,7 +958,7 @@ sub startup { $self->helper( 'journey_sanity_check' => sub { - my ( $self, $journey ) = @_; + my ( $self, $journey, $lax ) = @_; if ( $journey->{sched_duration} and $journey->{sched_duration} < 0 ) { @@ -983,7 +983,12 @@ sub startup { { return 'Zugfahrten mit über 500 km/h? Schön wär\'s.'; } - if ( $journey->{edited} & 0x0010 ) { + if ( $journey->{route} and @{ $journey->{route} } > 99 ) { + my $stop_count = @{ $journey->{route} }; + return +"Die Zugfahrt hat $stop_count Unterwegshalte. Also ich weiß ja nicht so recht."; + } + if ( $journey->{edited} & 0x0010 and not $lax ) { my @unknown_stations = $self->grep_unknown_stations( map { $_->[0] } @{ $journey->{route} } ); diff --git a/lib/Travelynx/Controller/Api.pm b/lib/Travelynx/Controller/Api.pm index 2e1fa49..54908fc 100755 --- a/lib/Travelynx/Controller/Api.pm +++ b/lib/Travelynx/Controller/Api.pm @@ -452,7 +452,8 @@ sub import_v1 { journey_id => $journey_id, verbose => 1 ); - $error = $self->journey_sanity_check($journey); + $error + = $self->journey_sanity_check( $journey, $payload->{lax} ? 1 : 0 ); } if ($error) { -- cgit v1.2.3