[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Friend_list module: Fixed 'user not found' error when adding a user

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <69150a8f936f5_2ce29f025237@gitlab-sidekiq-low-urgency-cpu-bound-v2-598795bdd5-6kqbx.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
7139d8b2 by Espoir Baraka at 2025-11-12T22:22:26+00:00
[FIX] Friend_list module: Fixed 'user not found' error when adding a user
---
* [FIX] Friend_list module: Fixed 'user not found' error when adding a user

See merge request tikiwiki/tiki!8881

- - - - -


1 changed file:

- lib/core/Services/User/SocialController.php


Changes:

=====================================
lib/core/Services/User/SocialController.php
=====================================
@@ -20,6 +20,20 @@ class Services_User_SocialController
         $this->lib = TikiLib::lib('social');
     }
 
+    private function resolveUsername($rawUsername)
+    {
+        $rawUsername = trim($rawUsername);
+
+        if (! $rawUsername) {
+            return '';
+        }
+
+        $userlib = TikiLib::lib('user');
+        $users = $userlib->find_best_user([$rawUsername], '', 'login');
+
+        return ! empty($users[0]) ? $users[0] : $rawUsername;
+    }
+
     public function action_list_friends($input)
     {
         global $user;
@@ -55,7 +69,8 @@ class Services_User_SocialController
     {
         global $user;
 
-        $username = $input->username->email();
+        $username = $this->resolveUsername($input->username->text());
+
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             if ($username) {
                 if (! $this->lib->addFriend($user, $username)) {
@@ -74,7 +89,8 @@ class Services_User_SocialController
     {
         global $user;
 
-        $username = $input->friend->email();
+        $username = $this->resolveUsername($input->friend->text());
+
         $status = null;
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             if ($username) {
@@ -95,7 +111,7 @@ class Services_User_SocialController
         global $user;
 
         $status = null;
-        $username = $input->friend->email();
+        $username = $this->resolveUsername($input->friend->text());
 
         if (! $username) {
             throw new Services_Exception_MissingValue('friend');



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7139d8b24acb483676315bf4371564d247403d99

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/7139d8b24acb483676315bf4371564d247403d99
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.