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

"Baraka Kinywa \(@bkinywa24\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6915a8de960b3_2ce2ce871635@gitlab-sidekiq-low-urgency-cpu-bound-v2-6b8bcc6cf6-p89rf.mail>

Baraka Kinywa pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki


Commits:
0899bb46 by Espoir Baraka at 2025-11-13T11:38:31+02: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
---
* [FIX] Friend_list module: Fixed 'user not found' error when adding a user

See merge request tikiwiki/tiki!8881

(cherry picked from commit 7139d8b24acb483676315bf4371564d247403d99)

See merge request tikiwiki/tiki!9018

- - - - -


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/0899bb46984c5be7c9bf284b1180a66e5f53d650

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0899bb46984c5be7c9bf284b1180a66e5f53d650
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.