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

fine-graned visibility selection of history / past checkins

most notably, adds a 'history for followers only' mode
parent 085d77a1
Loading
Loading
Loading
Loading
+54 −0
Original line number Diff line number Diff line
@@ -1589,6 +1589,60 @@ my @migrations = (
			}
		);
	},

	# v39 -> v40
	# distinguish between public / travelynx / followers / private visibility
	# for the history page, just like status visibility.
	sub {
		my ($db) = @_;
		$db->query(
			qq{
				alter table users alter public_level type integer;
			}
		);
		my $res = $db->select( 'users', [ 'id', 'public_level' ] );
		while ( my $row = $res->hash ) {
			my $old_level = $row->{public_level};

			# checkin and comment visibility remain unchanged
			my $new_level = $old_level & 0x00ff;

			# past: account required
			if ( $old_level & 0x100 ) {
				$new_level |= 80 << 8;
			}

			# past: public
			elsif ( $old_level & 0x200 ) {
				$new_level |= 100 << 8;
			}

			# past: private
			else {
				$new_level |= 10 << 8;
			}

			# past: infinite (default is 4 weeks)
			if ( $old_level & 0x400 ) {
				$new_level |= 0x10000;
			}

			# show past journey on status page
			if ( $old_level & 0x800 ) {
				$new_level |= 0x8000;
			}

			my $r = $db->update(
				'users',
				{ public_level => $new_level },
				{ id           => $row->{id} }
			)->rows;
			if ( $r != 1 ) {
				die("oh no");
			}
		}
		$db->update( 'schema_version', { version => 40 } );
	},
);

# TODO add 'hafas' column to in_transit (and maybe journeys? undo/redo needs something to work with...)
+7 −16
Original line number Diff line number Diff line
@@ -457,7 +457,6 @@ sub privacy {
	my ($self) = @_;

	my $user = $self->current_user;
	my $public_level = $user->{is_public};

	if ( $self->param('action') and $self->param('action') eq 'save' ) {
		my %opt;
@@ -467,21 +466,16 @@ sub privacy {
			$opt{default_visibility} = $default_visibility;
		}

		my $past_visibility = $visibility_atoi{ $self->param('history_level') };
		if ( defined $past_visibility ) {
			$opt{past_visibility} = $past_visibility;
		}

		$opt{comments_visible} = $self->param('public_comment') ? 1 : 0;

		$opt{past_all}    = $self->param('history_age') eq 'infinite' ? 1 : 0;
		$opt{past_status} = $self->param('past_status')               ? 1 : 0;

		if ( $self->param('history_level') eq 'intern' ) {
			$opt{past_visible} = 1;
		}
		elsif ( $self->param('history_level') eq 'extern' ) {
			$opt{past_visible} = 2;
		}
		else {
			$opt{past_visible} = 0;
		}

		$self->users->set_privacy(
			uid => $user->{id},
			%opt
@@ -495,10 +489,7 @@ sub privacy {
			status_level => $visibility_itoa{ $user->{default_visibility} } );
		$self->param( public_comment => $user->{comments_visible} );
		$self->param(
			  history_level => $user->{past_visible} & 0x01 ? 'intern'
			: $user->{past_visible} & 0x02 ? 'extern'
			:                                'private'
		);
			history_level => $visibility_itoa{ $user->{past_visibility} } );
		$self->param( history_age => $user->{past_all} ? 'infinite' : 'month' );
		$self->param( past_status => $user->{past_status} );
		$self->render( 'privacy', name => $user->{name} );
+7 −2
Original line number Diff line number Diff line
@@ -134,8 +134,13 @@ sub profile {

	my @journeys;

	if ( $user->{past_visible} == 2
		or ( $user->{past_visible} == 1 and ( $my_user or $is_self ) ) )
	if (
		$user->{past_visibility_str} eq 'public'
		or ( $user->{past_visibility_str} eq 'travelynx'
			and ( $my_user or $is_self ) )
		or ( $user->{past_visibility_str} eq 'followers'
			and ( ( $relation and $relation eq 'follows' ) or $is_self ) )
	  )
	{

		my %opt = (
+20 −15
Original line number Diff line number Diff line
@@ -192,9 +192,11 @@ sub get_privacy_by {
			default_visibility_str =>
			  $visibility_itoa{ $user->{public_level} & 0x7f },
			comments_visible    => $user->{public_level} & 0x80 ? 1 : 0,
			past_visible           => ( $user->{public_level} & 0x300 ) >> 8,
			past_all               => $user->{public_level} & 0x400 ? 1 : 0,
			past_status            => $user->{public_level} & 0x800 ? 1 : 0,
			past_visibility     => ( $user->{public_level} & 0x7f00 ) >> 8,
			past_visibility_str =>
			  $visibility_itoa{ ( $user->{public_level} & 0x7f00 ) >> 8 },
			past_status            => $user->{public_level} & 0x08000 ? 1 : 0,
			past_all               => $user->{public_level} & 0x10000 ? 1 : 0,
			accept_follows         => $user->{accept_follows} == 2    ? 1 : 0,
			accept_follow_requests => $user->{accept_follows} == 1    ? 1 : 0,
		};
@@ -211,9 +213,10 @@ sub set_privacy {
	if ( not defined $public_level and defined $opt{default_visibility} ) {
		$public_level
		  = ( $opt{default_visibility} & 0x7f )
		  | ( $opt{comments_visible} ? 0x80 : 0x00 )
		  | ( ( ( $opt{past_visible} // 0 ) << 8 ) & 0x300 )
		  | ( $opt{past_all} ? 0x400 : 0 ) | ( $opt{past_status} ? 0x800 : 0 );
		  | ( $opt{comments_visible} ? 0x80 : 0 )
		  | ( ( $opt{past_visibility} & 0x7f ) << 8 )
		  | ( $opt{past_status} ? 0x08000 : 0 )
		  | ( $opt{past_all}    ? 0x10000 : 0 );
	}

	$db->update( 'users', { public_level => $public_level }, { id => $uid } );
@@ -417,9 +420,11 @@ sub get {
			default_visibility_str =>
			  $visibility_itoa{ $user->{public_level} & 0x7f },
			comments_visible    => $user->{public_level} & 0x80 ? 1 : 0,
			past_visible     => ( $user->{public_level} & 0x300 ) >> 8,
			past_all         => $user->{public_level} & 0x400 ? 1 : 0,
			past_status      => $user->{public_level} & 0x800 ? 1 : 0,
			past_visibility     => ( $user->{public_level} & 0x7f00 ) >> 8,
			past_visibility_str =>
			  $visibility_itoa{ ( $user->{public_level} & 0x7f00 ) >> 8 },
			past_status => $user->{public_level} & 0x08000 ? 1 : 0,
			past_all    => $user->{public_level} & 0x10000 ? 1 : 0,
			email       => $user->{email},
			sb_name     => $user->{external_services}
			? $sb_templates[ $user->{external_services} & 0x07 ][0]
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@
				<td>
					<a href="/account/privacy"><i class="material-icons">edit</i></a>
					<i class="material-icons"><%= visibility_icon($acc->{default_visibility_str}) %></i>
					• <i class="material-icons"><%= visibility_icon($acc->{past_visibility_str}) %></i>
					• <a href="/p/<%= $acc->{name} %>">Öffentliches Profil</a>
				</td>
			</tr>
Loading