summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Travelynx/Controller/Traewelling.pm10
-rw-r--r--lib/Travelynx/Helper/Traewelling.pm4
-rw-r--r--lib/Travelynx/Model/Traewelling.pm18
3 files changed, 24 insertions, 8 deletions
diff --git a/lib/Travelynx/Controller/Traewelling.pm b/lib/Travelynx/Controller/Traewelling.pm
index 78c501f..5a37b6e 100644
--- a/lib/Travelynx/Controller/Traewelling.pm
+++ b/lib/Travelynx/Controller/Traewelling.pm
@@ -76,7 +76,9 @@ sub settings {
$self->traewelling->set_sync(
uid => $uid,
push_sync => $self->param('sync_source') eq 'travelynx' ? 1 : 0,
- pull_sync => $self->param('sync_source') eq 'traewelling' ? 1 : 0
+ pull_sync => $self->param('sync_source') eq 'traewelling' ? 1 : 0,
+ toot => $self->param('toot') ? 1 : 0,
+ tweet => $self->param('tweet') ? 1 : 0,
);
$self->flash( success => 'traewelling' );
$self->redirect_to('account');
@@ -94,6 +96,12 @@ sub settings {
else {
$self->param( sync_source => 'none' );
}
+ if ( $traewelling->{data}{toot} ) {
+ $self->param( toot => 1 );
+ }
+ if ( $traewelling->{data}{tweet} ) {
+ $self->param( tweet => 1 );
+ }
$self->render(
'traewelling',
diff --git a/lib/Travelynx/Helper/Traewelling.pm b/lib/Travelynx/Helper/Traewelling.pm
index 6d7c367..2a522e5 100644
--- a/lib/Travelynx/Helper/Traewelling.pm
+++ b/lib/Travelynx/Helper/Traewelling.pm
@@ -286,6 +286,8 @@ sub checkin {
tripID => $opt{trip_id},
start => q{} . $opt{dep_eva},
destination => q{} . $opt{arr_eva},
+ toot => $opt{data}{toot} ? \1 : \0,
+ tweet => $opt{data}{tweet} ? \1 : \0,
};
my $trip_req = sprintf(
"tripID=%s&lineName=%s%%20%s&start=%s",
@@ -321,7 +323,7 @@ sub checkin {
);
return;
}
- $self->{log}->debug("... success!");
+ $self->{log}->debug( "... success! " . $tx->res->body );
# As of 2020-10-04, traewelling.de checkins do not yet return
# "statusId". The patch is present on the develop branch and waiting
diff --git a/lib/Travelynx/Model/Traewelling.pm b/lib/Travelynx/Model/Traewelling.pm
index c9b2181..f320a35 100644
--- a/lib/Travelynx/Model/Traewelling.pm
+++ b/lib/Travelynx/Model/Traewelling.pm
@@ -182,15 +182,21 @@ sub set_latest_push_ts {
sub set_sync {
my ( $self, %opt ) = @_;
- my $uid = $opt{uid};
- my $push_sync = $opt{push_sync};
- my $pull_sync = $opt{pull_sync};
+ my $uid = $opt{uid};
+ my $db = $opt{db} // $self->{pg}->db;
- $self->{pg}->db->update(
+ my $res_h
+ = $db->select( 'traewelling', 'data', { user_id => $uid } )->expand->hash;
+
+ $res_h->{data}{toot} = $opt{toot};
+ $res_h->{data}{tweet} = $opt{tweet};
+
+ $db->update(
'traewelling',
{
- push_sync => $push_sync,
- pull_sync => $pull_sync
+ push_sync => $opt{push_sync},
+ pull_sync => $opt{pull_sync},
+ data => JSON->new->encode( $res_h->{data} ),
},
{ user_id => $uid }
);