summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2022-02-16 20:56:28 +0100
committerDaniel Friesel <derf@finalrewind.org>2022-02-16 20:56:28 +0100
commit167b01fa4264a8193ff3cbd9d3f1741f5702235a (patch)
tree6b03555ced3c757269898f8f7ebf46506aa2b06a /lib
parentef3252863e28905fe96a49a91e5a62c156c69e6e (diff)
link traewelling profile from travelynx profile; show traewelling status
Diffstat (limited to 'lib')
-rwxr-xr-xlib/Travelynx.pm21
-rw-r--r--lib/Travelynx/Controller/Traewelling.pm7
-rw-r--r--lib/Travelynx/Helper/Traewelling.pm7
3 files changed, 29 insertions, 6 deletions
diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm
index 8e29114..40ca0a5 100755
--- a/lib/Travelynx.pm
+++ b/lib/Travelynx.pm
@@ -1822,6 +1822,27 @@ sub startup {
comment => $in_transit->{user_data}{comment},
};
+ my $traewelling = $self->traewelling->get(
+ uid => $uid,
+ db => $db
+ );
+ if ( $traewelling->{latest_run}
+ >= epoch_to_dt( $in_transit->{checkin_ts} ) )
+ {
+ $ret->{traewelling} = $traewelling;
+ if ( @{ $traewelling->{data}{log} // [] }
+ and ( my $log_entry = $traewelling->{data}{log}[0] ) )
+ {
+ if ( $log_entry->[2] ) {
+ $ret->{traewelling_status} = $log_entry->[2];
+ $ret->{traewelling_url}
+ = 'https://traewelling.de/status/'
+ . $log_entry->[2];
+ }
+ $ret->{traewelling_log_latest} = $log_entry->[1];
+ }
+ }
+
my @parsed_messages;
for my $message ( @{ $ret->{messages} // [] } ) {
my ( $ts, $msg ) = @{$message};
diff --git a/lib/Travelynx/Controller/Traewelling.pm b/lib/Travelynx/Controller/Traewelling.pm
index d3e6d6c..21fa3e9 100644
--- a/lib/Travelynx/Controller/Traewelling.pm
+++ b/lib/Travelynx/Controller/Traewelling.pm
@@ -1,4 +1,5 @@
package Travelynx::Controller::Traewelling;
+
# Copyright (C) 2020 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later
@@ -78,10 +79,10 @@ sub settings {
elsif ( $self->param('action') and $self->param('action') eq 'config' ) {
$self->traewelling->set_sync(
uid => $uid,
- push_sync => $self->param('sync_source') eq 'travelynx' ? 1 : 0,
+ push_sync => $self->param('sync_source') eq 'travelynx' ? 1 : 0,
pull_sync => $self->param('sync_source') eq 'traewelling' ? 1 : 0,
- toot => $self->param('toot') ? 1 : 0,
- tweet => $self->param('tweet') ? 1 : 0,
+ toot => $self->param('toot') ? 1 : 0,
+ tweet => $self->param('tweet') ? 1 : 0,
);
$self->flash( success => 'traewelling' );
$self->redirect_to('account');
diff --git a/lib/Travelynx/Helper/Traewelling.pm b/lib/Travelynx/Helper/Traewelling.pm
index 03db4d2..401d9a6 100644
--- a/lib/Travelynx/Helper/Traewelling.pm
+++ b/lib/Travelynx/Helper/Traewelling.pm
@@ -362,7 +362,7 @@ sub checkin {
$self->{model}->log(
uid => $opt{uid},
message =>
- "Fehler bei $opt{train_type} $opt{train_no}: $err_msg",
+"Checkin-Fehler bei $opt{train_type} $opt{train_no}: $err_msg",
is_error => 1
);
return;
@@ -390,8 +390,9 @@ sub checkin {
my ($err) = @_;
$self->{log}->debug("... error: $err");
$self->{model}->log(
- uid => $opt{uid},
- message => "Fehler bei $opt{train_type} $opt{train_no}: $err",
+ uid => $opt{uid},
+ message =>
+ "Checkin-Fehler bei $opt{train_type} $opt{train_no}: $err",
is_error => 1
);
}