From 19cd9f7a8d888302d8637af897d407fc34bab522 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sun, 16 Jul 2023 23:01:23 +0200 Subject: account: add a list of sent follow requests --- lib/Travelynx/Model/Users.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'lib/Travelynx/Model/Users.pm') diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index 8f1714d..0665f6a 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -809,8 +809,8 @@ sub get_relation { } return; - #my $res_h = $db->select( 'relations', ['subject_id', 'predicate'], - # { subject_id => [$uid, $target], object_id => [$target, $target] } )->hash; + #my $res_h = $db->select( 'relations', ['subject_id', 'predicate'], + # { subject_id => [$uid, $target], object_id => [$target, $target] } )->hash; } sub update_notifications { @@ -1096,11 +1096,12 @@ sub has_followers { sub get_follow_requests { my ( $self, %opt ) = @_; - my $db = $opt{db} // $self->{pg}->db; - my $uid = $opt{uid}; + my $db = $opt{db} // $self->{pg}->db; + my $uid = $opt{uid}; + my $table = $opt{sent} ? 'tx_follow_requests' : 'rx_follow_requests'; my $res - = $db->select( 'follow_requests', [ 'id', 'name' ], { self_id => $uid } ); + = $db->select( $table, [ 'id', 'name' ], { self_id => $uid } ); return $res->hashes->each; } @@ -1108,11 +1109,12 @@ sub get_follow_requests { sub has_follow_requests { my ( $self, %opt ) = @_; - my $db = $opt{db} // $self->{pg}->db; - my $uid = $opt{uid}; + my $db = $opt{db} // $self->{pg}->db; + my $uid = $opt{uid}; + my $table = $opt{sent} ? 'tx_follow_requests' : 'rx_follow_requests'; - return $db->select( 'follow_requests', 'count(*) as count', - { self_id => $uid } )->hash->{count}; + return $db->select( $table, 'count(*) as count', { self_id => $uid } ) + ->hash->{count}; } sub get_followees { -- cgit v1.2.3