From 562dd7ccaef9270070d142e9d6cfe8aa164e072e Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 4 Oct 2020 12:27:20 +0200 Subject: add toot and tweet settings to traewelling checkin --- lib/Travelynx/Model/Traewelling.pm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/Travelynx/Model/Traewelling.pm') 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 } ); -- cgit v1.2.3