add toot and tweet settings to traewelling checkin
This commit is contained in:
parent
7ef1fe06b9
commit
562dd7ccae
3 changed files with 24 additions and 8 deletions
|
@ -76,7 +76,9 @@ sub settings {
|
||||||
$self->traewelling->set_sync(
|
$self->traewelling->set_sync(
|
||||||
uid => $uid,
|
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
|
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->flash( success => 'traewelling' );
|
||||||
$self->redirect_to('account');
|
$self->redirect_to('account');
|
||||||
|
@ -94,6 +96,12 @@ sub settings {
|
||||||
else {
|
else {
|
||||||
$self->param( sync_source => 'none' );
|
$self->param( sync_source => 'none' );
|
||||||
}
|
}
|
||||||
|
if ( $traewelling->{data}{toot} ) {
|
||||||
|
$self->param( toot => 1 );
|
||||||
|
}
|
||||||
|
if ( $traewelling->{data}{tweet} ) {
|
||||||
|
$self->param( tweet => 1 );
|
||||||
|
}
|
||||||
|
|
||||||
$self->render(
|
$self->render(
|
||||||
'traewelling',
|
'traewelling',
|
||||||
|
|
|
@ -286,6 +286,8 @@ sub checkin {
|
||||||
tripID => $opt{trip_id},
|
tripID => $opt{trip_id},
|
||||||
start => q{} . $opt{dep_eva},
|
start => q{} . $opt{dep_eva},
|
||||||
destination => q{} . $opt{arr_eva},
|
destination => q{} . $opt{arr_eva},
|
||||||
|
toot => $opt{data}{toot} ? \1 : \0,
|
||||||
|
tweet => $opt{data}{tweet} ? \1 : \0,
|
||||||
};
|
};
|
||||||
my $trip_req = sprintf(
|
my $trip_req = sprintf(
|
||||||
"tripID=%s&lineName=%s%%20%s&start=%s",
|
"tripID=%s&lineName=%s%%20%s&start=%s",
|
||||||
|
@ -321,7 +323,7 @@ sub checkin {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$self->{log}->debug("... success!");
|
$self->{log}->debug( "... success! " . $tx->res->body );
|
||||||
|
|
||||||
# As of 2020-10-04, traewelling.de checkins do not yet return
|
# As of 2020-10-04, traewelling.de checkins do not yet return
|
||||||
# "statusId". The patch is present on the develop branch and waiting
|
# "statusId". The patch is present on the develop branch and waiting
|
||||||
|
|
|
@ -183,14 +183,20 @@ sub set_sync {
|
||||||
my ( $self, %opt ) = @_;
|
my ( $self, %opt ) = @_;
|
||||||
|
|
||||||
my $uid = $opt{uid};
|
my $uid = $opt{uid};
|
||||||
my $push_sync = $opt{push_sync};
|
my $db = $opt{db} // $self->{pg}->db;
|
||||||
my $pull_sync = $opt{pull_sync};
|
|
||||||
|
|
||||||
$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',
|
'traewelling',
|
||||||
{
|
{
|
||||||
push_sync => $push_sync,
|
push_sync => $opt{push_sync},
|
||||||
pull_sync => $pull_sync
|
pull_sync => $opt{pull_sync},
|
||||||
|
data => JSON->new->encode( $res_h->{data} ),
|
||||||
},
|
},
|
||||||
{ user_id => $uid }
|
{ user_id => $uid }
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue