From 57a86d97940984f7c3d1735f697e6db9efdb377e Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 3 Jan 2022 20:16:41 +0200 Subject: [PATCH] remove self-unfollowing feature --- .../controller/api/follow/delete.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/application/controller/api/follow/delete.php b/src/application/controller/api/follow/delete.php index 45ae9cf..ca2968f 100644 --- a/src/application/controller/api/follow/delete.php +++ b/src/application/controller/api/follow/delete.php @@ -7,12 +7,24 @@ $response = [ if (isset($_SESSION['userName']) && isset($_POST['userName'])) { - $result = $_twister->unFollow($_SESSION['userName'], [$_POST['userName']]); + $userName = Filter::userName($_POST['userName']); - $response = [ - 'success' => true, - 'message' => _('Unfollowed successfully'), - ]; + if ($_SESSION['userName'] != $userName) { + + $_twister->unFollow($_SESSION['userName'], [$userName]); + + $response = [ + 'success' => true, + 'message' => _('Unfollowed successfully'), + ]; + + } else { + + $response = [ + 'success' => false, + 'message' => _("Can't unfollow yourself"), + ]; + } } else {