From fef9ebe0b20623c4e21cf720ea379338e6ef978e Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Tue, 18 Jul 2023 15:47:45 +0200 Subject: followee list: show if accounts are following back --- lib/Travelynx/Model/Users.pm | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'lib/Travelynx/Model/Users.pm') diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index 0665f6a..c51e612 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -1123,9 +1123,27 @@ sub get_followees { my $db = $opt{db} // $self->{pg}->db; my $uid = $opt{uid}; - my $res = $db->select( 'followees', [ 'id', 'name' ], { self_id => $uid } ); + my $res = $db->select( + 'followees', + [ 'id', 'name', 'inverse_predicate' ], + { self_id => $uid } + ); - return $res->hashes->each; + my @ret; + while ( my $row = $res->hash ) { + push( + @ret, + { + id => $row->{id}, + name => $row->{name}, + following_back => ( + $row->{inverse_predicate} + and $row->{inverse_predicate} == $predicate_atoi{follows} + ) ? 1 : 0, + } + ); + } + return @ret; } sub has_followees { -- cgit v1.2.3