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(
|
||||
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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue