fine-graned visibility selection of history / past checkins
most notably, adds a 'history for followers only' mode
This commit is contained in:
parent
085d77a1fa
commit
b44b770ec3
6 changed files with 123 additions and 47 deletions
|
@ -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...)
|
||||
|
|
|
@ -456,8 +456,7 @@ sub do_logout {
|
|||
sub privacy {
|
||||
my ($self) = @_;
|
||||
|
||||
my $user = $self->current_user;
|
||||
my $public_level = $user->{is_public};
|
||||
my $user = $self->current_user;
|
||||
|
||||
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} );
|
||||
|
|
|
@ -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 = (
|
||||
|
|
|
@ -191,12 +191,14 @@ sub get_privacy_by {
|
|||
default_visibility => $user->{public_level} & 0x7f,
|
||||
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,
|
||||
accept_follows => $user->{accept_follows} == 2 ? 1 : 0,
|
||||
accept_follow_requests => $user->{accept_follows} == 1 ? 1 : 0,
|
||||
comments_visible => $user->{public_level} & 0x80 ? 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,
|
||||
};
|
||||
}
|
||||
return;
|
||||
|
@ -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 } );
|
||||
|
@ -416,12 +419,14 @@ sub get {
|
|||
default_visibility => $user->{public_level} & 0x7f,
|
||||
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,
|
||||
email => $user->{email},
|
||||
sb_name => $user->{external_services}
|
||||
comments_visible => $user->{public_level} & 0x80 ? 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]
|
||||
: undef,
|
||||
sb_template => $user->{external_services}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -85,20 +85,40 @@
|
|||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<div>
|
||||
<label>
|
||||
%= radio_button history_level => 'private'
|
||||
<span>Nicht sichtbar</span>
|
||||
</label>
|
||||
</div><div>
|
||||
<label>
|
||||
%= radio_button history_level => 'intern'
|
||||
<span>Nur mit Anmeldung</span>
|
||||
</label>
|
||||
</div><div>
|
||||
<label>
|
||||
%= radio_button history_level => 'extern'
|
||||
<span>Öffentlich</span>
|
||||
</label>
|
||||
<label>
|
||||
%= radio_button history_level => 'public'
|
||||
<span><i class="material-icons left"><%= visibility_icon('public') %></i>Öffentlich: Beliebig zugänglich.</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<div>
|
||||
<label>
|
||||
%= radio_button history_level => 'travelynx'
|
||||
<span><i class="material-icons left"><%= visibility_icon('travelynx') %></i>Intern: Personen, die dir folgen oder die auf dieser Seite angemeldet sind.</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<div>
|
||||
<label>
|
||||
%= radio_button history_level => 'followers'
|
||||
<span><i class="material-icons left"><%= visibility_icon('followers') %></i>Follower: Personen, die dir folgen.</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<div>
|
||||
<label>
|
||||
%= radio_button history_level => 'private'
|
||||
<span><i class="material-icons left"><%= visibility_icon('private') %></i>Privat: nur für dich sichtbar.</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue