my @expose_user_fields = qw/id usrname first_given_name second_given_name family_name alias/;
my $out_links_query = {
- select => {cubi => ['target_user']},
+ select => {cubi => ['target_user']},
from => {
cub => {
cubi => {field => 'bucket', fkey => 'id'}
}
- },
+ },
where => {
'+cub' => {btype => 'folks', owner => undef}
}
};
-my $in_links_query = {
- select => {cub => ['owner'] },
+my $in_links_query = {
+ select => {cub => ['owner'] },
from => {
cub => {
cubi => {field => 'bucket', fkey => 'id'}
}
- },
+ },
where => {
- '+cubi' => {target_user => undef},
+ '+cubi' => {target_user => undef},
'+cub' => {btype => 'folks'}
}
};
-my $perm_check_query = {
- select => {cub => ['btype'] },
+my $perm_check_query = {
+ select => {cub => ['btype'] },
from => {
cub => {
cubi => {field => 'bucket', fkey => 'id'}
}
- },
+ },
};
sub retrieve_friends {
$in_links_query->{where}->{'+cubi'}->{target_user} = $user_id;
my @in_linked = map {$_->{owner}} @{$e->json_query($in_links_query)};
- # determine which users are confirmed, pending outbound
+ # determine which users are confirmed, pending outbound
# requests, and pending inbound requests
my @confirmed;
my @pending_out;
my $items = [];
# use this query to retrieve trimmed linked user objects
- my $user_select =
+ my $user_select =
{select => {au => \@expose_user_fields}, from => 'au', where => undef};
for my $d_user (@users) {
- # fetch all of the bucket items linked from base user to
+ # fetch all of the bucket items linked from base user to
# delegate user with the folks: prefix on the bucket type
$perm_check_query->{where} = {
'+cubi' => {target_user => $d_user},
'+cub' => {btype => {like => 'folks:%'}, owner => $user_id}
};
- my $perms_granted = [
+ my $perms_granted = [
map {substr($_->{btype}, 6)} @{$e->json_query($perm_check_query)}];
- # fetch all of the bucket items linked from the delegate user
+ # fetch all of the bucket items linked from the delegate user
# to the base user with the folks: prefix on the bucket type
$perm_check_query->{where} = {
'+cubi' => {target_user => $user_id},
'+cub' => {btype => {like => 'folks:%'}, owner => $d_user}
};
- my $perms_received = [
+ my $perms_received = [
map {substr($_->{btype}, 6)} @{$e->json_query($perm_check_query)}];
$user_select->{where} = {id => $d_user};
}
-my $direct_links_query = {
- select => {cub => ['id'] },
+my $direct_links_query = {
+ select => {cub => ['id'] },
from => {
cub => {
cubi => {field => 'bucket', fkey => 'id'}
}
- },
+ },
where => {
- '+cubi' => {target_user => undef},
+ '+cubi' => {target_user => undef},
'+cub' => {btype => 'folks', owner => undef}
},
limit => 1
$direct_links_query->{where}->{'+cubi'}->{target_user} = $user2_id;
if($e->json_query($direct_links_query)->[0]) {
-
$direct_links_query->{where}->{'+cub'}->{owner} = $user2_id;
$direct_links_query->{where}->{'+cubi'}->{target_user} = $user1_id;
return 1 if $e->json_query($direct_links_query)->[0];