Unverified Commit 6fc21cac authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Use correct base URL when running a command job (work/maintenance)

parent 170c7e42
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -5,6 +5,16 @@
# 'localhost'.

{
	# Base URL of this travelynx installation, e.g. "https://travelynx.de" for
	# travelynx.de. Used to identify this travelynx instance when performing API
	# requests (so API providers know whom to contact case of issues) and for
	# imprint and other links in travelynx E-Mails. Note that this entry is
	# only used when travelynx is performing requests or sending E-mails from
	# a "work", "worker", or "maintenance" job. Otherwise, it will infer the
	# base URL from the HTTP request.  If your travelynx instance is reachable
	# via multiple URLs, use any one of them.
	base_url => Mojo::URL->new('https://FIXME.local'),

	# travelynx relies on several backend projects. You may override the
	# defaults to use other (e.g. self-hosted) instances.
	backend => {
+15 −4
Original line number Diff line number Diff line
@@ -276,6 +276,17 @@ sub startup {
		}
	);

	$self->helper(
		base_url_for => sub {
			my ( $self, $path ) = @_;
			if ( ( my $url = $self->url_for($path) )->base ne q{} ) {
				return $url;
			}
			return $self->url_for($path)
			  ->base( $self->app->config->{base_url} );
		}
	);

	$self->helper(
		hafas => sub {
			my ($self) = @_;
@@ -284,7 +295,7 @@ sub startup {
				hafas_rest_api => $self->app->config->{backend}{hafas_rest_api},
				main_cache     => $self->app->cache_iris_main,
				realtime_cache => $self->app->cache_iris_rt,
				root_url       => $self->url_for('/')->to_abs,
				root_url       => $self->base_url_for('/')->to_abs,
				user_agent     => $self->ua,
				version        => $self->app->config->{version},
			);
@@ -298,7 +309,7 @@ sub startup {
				log            => $self->app->log,
				main_cache     => $self->app->cache_iris_main,
				realtime_cache => $self->app->cache_iris_rt,
				root_url       => $self->url_for('/')->to_abs,
				root_url       => $self->base_url_for('/')->to_abs,
				version        => $self->app->config->{version},
			);
		}
@@ -317,7 +328,7 @@ sub startup {
			state $trwl_api = Travelynx::Helper::Traewelling->new(
				log        => $self->app->log,
				model      => $self->traewelling,
				root_url   => $self->url_for('/')->to_abs,
				root_url   => $self->base_url_for('/')->to_abs,
				user_agent => $self->ua,
				version    => $self->app->config->{version},
			);
@@ -406,7 +417,7 @@ sub startup {
			state $dbdb = Travelynx::Helper::DBDB->new(
				log        => $self->app->log,
				cache      => $self->app->cache_iris_main,
				root_url   => $self->url_for('/')->to_abs,
				root_url   => $self->base_url_for('/')->to_abs,
				user_agent => $self->ua,
				version    => $self->app->config->{version},
			);