Unverified Commit 882d1fe1 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

Merge branch 'networkException-träwelling-visibility'

parents 6c5caaf2 ee2d8bd0
Loading
Loading
Loading
Loading

.mailmap

0 → 100644
+1 −0
Original line number Diff line number Diff line
Birte Kristina Friesel <derf@finalrewind.org>
+30 −0
Original line number Diff line number Diff line
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,33 @@ sub logout_p {
	return $promise;
}

sub convert_travelynx_to_traewelling_visibility {
	my ($travelynx_visibility) = @_;

	my %visibilities = (

		# public    => StatusVisibility::PUBLIC
		100 => 0,

		# travelynx => StatusVisibility::AUTHENTICATED
		# (only visible for logged in users)
		80 => 4,

		# followers => StatusVisibility::FOLLOWERS
		60 => 2,

		# unlisted  => StatusVisibility::PRIVATE
		# (there is no träwelling equivalent to unlisted, their
		# StatusVisibility::UNLISTED shows the journey on the profile)
		30 => 3,

		# private   => StatusVisibility::PRIVATE
		10 => 3,
	);

	return $visibilities{$travelynx_visibility};
}

sub checkin_p {
	my ( $self, %opt ) = @_;

@@ -352,6 +380,8 @@ 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} ) {
+7 −6
Original line number Diff line number Diff line
@@ -213,16 +213,17 @@ sub get_pushable_accounts {
	my $res = $self->{pg}->db->query(
		qq{select t.user_id as uid, t.token as token, t.data as data,
			i.user_data as user_data,
			i.checkin_station_id as dep_eva, i.checkout_station_id as arr_eva,
			i.dep_eva as dep_eva, i.arr_eva as arr_eva,
			i.data as journey_data, i.train_type as train_type,
			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
			i.checkin_ts as checkin_ts,
			i.sched_dep_ts as dep_ts,
			i.sched_arr_ts as arr_ts,
			i.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 on t.user_id = i.user_id
			where t.push_sync = True
			and i.checkout_station_id is not null
			and i.arr_eva is not null
			and i.cancelled = False
		}
	);
+4 −3
Original line number Diff line number Diff line
@@ -191,8 +191,8 @@
				<p>Die Synchronisierung erfolgt spätestens drei Minuten nach der
					Zielwahl. Beachte, dass die Synchronisierung travelynx
					→ Träwelling unabhängig von der eingestellten Sichtbarkeit
					des Checkins erfolgt und Träwelling-Sichtbarkeiten
					derzeit ebenfalls nicht von travelynx übernommen werden.
					des Checkins erfolgt. travelynx reicht die Sichtbarkeit
					aber an Träwelling weiter.
					Träwelling-Checkins können von travelynx aktuell nicht
					rückgängig gemacht werden. Eine nachträgliche Änderung der
					Zielstation wird nicht übernommen. Mastodon und Twitter beziehen
@@ -211,7 +211,8 @@
					Falls du gerade in einen Zug eingecheckt bist, wird dieser von
					travelynx übernommen.  Träwelling-Checkins in Nahverkehrsmittel
					und Züge außerhalb des deutschen Schienennetzes werden nicht
					unterstützt.</p>
					unterstützt. Die Sichtbarkeit von Träwelling-Checkins wird
					derzeit von travelynx nicht berücksichtigt.</p>
			</div>
		</div>
		<div class="row hide-on-small-only">