diff options
author | Derf Null <derf@finalrewind.org> | 2023-05-24 21:36:06 +0200 |
---|---|---|
committer | Derf Null <derf@finalrewind.org> | 2023-05-24 21:36:06 +0200 |
commit | ac816c09b23233c9e3de0f1b12cc905a921ca85a (patch) | |
tree | 4295ea2e8a148e07af3db5f79894acfb106c66b0 /lib/Travelynx/Model | |
parent | 68468379e5f60e257f7276d08251d93db4af6ea2 (diff) |
rename get_privacy_by_name to get_privacy_by, allow requests by uid
Diffstat (limited to 'lib/Travelynx/Model')
-rw-r--r-- | lib/Travelynx/Model/Users.pm | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index af2a6dc..67296ca 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -154,19 +154,21 @@ sub get_uid_by_name_and_mail { return; } -sub get_privacy_by_name { +sub get_privacy_by { my ( $self, %opt ) = @_; - my $db = $opt{db} // $self->{pg}->db; - my $name = $opt{name}; + my $db = $opt{db} // $self->{pg}->db; - my $res = $db->select( - 'users', - [ 'id', 'public_level' ], - { - name => $name, - status => 1 - } - ); + my %where; + + if ( $opt{name} ) { + $where{name} = $opt{name}; + } + else { + $where{id} = $opt{uid}; + } + + my $res = $db->select( 'users', [ 'id', 'public_level' ], + { %where, status => 1 } ); if ( my $user = $res->hash ) { return { |