get_user_status_json_v1: expose visibility

This commit is contained in:
Derf Null 2023-05-24 21:41:51 +02:00
parent ac816c09b2
commit 7580497cea
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
2 changed files with 15 additions and 3 deletions

View file

@ -1695,7 +1695,9 @@ sub startup {
$self->helper(
'get_user_status_json_v1' => sub {
my ( $self, %opt ) = @_;
my $uid = $opt{uid};
my $uid = $opt{uid};
my $privacy = $opt{privacy}
// $self->users->get_privacy_by( uid => $uid );
my $status = $opt{status} // $self->get_user_status($uid);
my $ret = {
@ -1737,6 +1739,15 @@ sub startup {
id => $status->{train_id},
},
intermediateStops => [],
visibility => {
level => $status->{visibility}
// $privacy->{default_visibility},
desc => (
$status->{visibility_str} eq 'default'
? $privacy->{default_visibility_str}
: $status->{visibility_str}
),
}
};
if ( not $opt{public} ) {

View file

@ -410,8 +410,9 @@ sub user_status {
json => {
name => $name,
status => $self->get_user_status_json_v1(
status => $status,
public => 1
status => $status,
privacy => $user,
public => 1
),
version => $self->app->config->{version} // 'UNKNOWN',
},