Skip to content
Snippets Groups Projects
Unverified Commit 0c1993f2 authored by networkException's avatar networkException
Browse files

Checkin: Use correct visibility when pushing to Träwelling

parent a28db4a4
No related branches found
No related tags found
No related merge requests found
package Travelynx::Helper::Traewelling;
# Copyright (C) 2020-2023 Birte Kristina Friesel
# Copyright (C) 2023 networkException <git@nwex.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
......@@ -322,6 +323,20 @@ sub logout_p {
return $promise;
}
sub convert_travelynx_to_traewelling_visibility {
my ( $travelynx_visibility ) = @_;
my %visibilities = (
100 => 0, # public => StatusVisibility::PUBLIC
80 => 4, # travelynx => StatusVisibility::AUTHENTICATED (only visible for logged in users)
60 => 2, # followers => StatusVisibility::FOLLOWERS
30 => 3, # unlisted => StatusVisibility::PRIVATE (there is no träwelling equivalent to unlisted, their StatusVisibility::UNLISTED shows the journey on the profile)
10 => 3, # private => StatusVisibility::PRIVATE
);
return $visibilities{$travelynx_visibility};
}
sub checkin_p {
my ( $self, %opt ) = @_;
......@@ -352,6 +367,7 @@ sub checkin_p {
arrival => $arrival_ts,
toot => $opt{data}{toot} ? \1 : \0,
tweet => $opt{data}{tweet} ? \1 : \0,
visibility => convert_travelynx_to_traewelling_visibility($opt{visibility})
};
if ( $opt{user_data}{comment} ) {
......
......@@ -218,9 +218,11 @@ sub get_pushable_accounts {
i.train_line as train_line, i.train_no as train_no,
extract(epoch from i.checkin_time) as checkin_ts,
extract(epoch from i.sched_departure) as dep_ts,
extract(epoch from i.sched_arrival) as arr_ts
extract(epoch from i.sched_arrival) as arr_ts,
i_str.effective_visibility as visibility
from traewelling as t
join in_transit as i on t.user_id = i.user_id
join in_transit_str as i_str on t.user_id = i_str.user_id
where t.push_sync = True
and i.checkout_station_id is not null
and i.cancelled = False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment