From b2feb1b664c575ce04a4a00c1a860ef07dae732d Mon Sep 17 00:00:00 2001 From: Derf Null Date: Thu, 1 Jun 2023 22:07:01 +0200 Subject: Users: Add unfollow action --- lib/Travelynx/Model/Users.pm | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'lib/Travelynx/Model/Users.pm') diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index 9b0a115..4444dc9 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -803,23 +803,33 @@ sub reject_follow_request { ); } -sub remove_follower { +sub unfollow { my ( $self, %opt ) = @_; - my $db = $opt{db} // $self->{pg}->db; - my $uid = $opt{uid}; - my $follower = $opt{follower}; + my $db = $opt{db} // $self->{pg}->db; + my $uid = $opt{uid}; + my $target = $opt{target}; $db->delete( 'relations', { - subject_id => $follower, + subject_id => $uid, predicate => $predicate_atoi{follows}, - object_id => $uid + object_id => $target } ); } +sub remove_follower { + my ( $self, %opt ) = @_; + + $self->unfollow( + db => $opt{db}, + uid => $opt{follower}, + target => $opt{uid}, + ); +} + sub block { my ( $self, %opt ) = @_; -- cgit v1.2.3