2828use OCP \Collaboration \Collaborators \ISearchResult ;
2929use OCP \Collaboration \Collaborators \SearchResultType ;
3030use OCP \Contacts \IManager ;
31+ use OCP \Federation \ICloudId ;
3132use OCP \Federation \ICloudIdManager ;
3233use OCP \IConfig ;
3334use OCP \IGroupManager ;
35+ use OCP \IUser ;
3436use OCP \IUserSession ;
3537use OCP \Share ;
3638
@@ -112,7 +114,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
112114 continue ;
113115 }
114116
115- if (!$ searchResult ->hasResult ($ userType , $ cloud ->getUser ())) {
117+ if (!$ this -> isCurrentUser ( $ cloud ) && ! $ searchResult ->hasResult ($ userType , $ cloud ->getUser ())) {
116118 $ singleResult = [[
117119 'label ' => $ contact ['FN ' ] . " ( $ emailAddress) " ,
118120 'value ' => [
@@ -133,7 +135,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
133135 continue ;
134136 }
135137
136- if (!$ searchResult ->hasResult ($ userType , $ cloud ->getUser ())) {
138+ if (!$ this -> isCurrentUser ( $ cloud ) && ! $ searchResult ->hasResult ($ userType , $ cloud ->getUser ())) {
137139 $ singleResult = [[
138140 'label ' => $ contact ['FN ' ] . " ( $ emailAddress) " ,
139141 'value ' => [
@@ -189,4 +191,9 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
189191
190192 return true ;
191193 }
194+
195+ public function isCurrentUser (ICloudId $ cloud ): bool {
196+ $ currentUser = $ this ->userSession ->getUser ();
197+ return $ currentUser instanceof IUser ? $ currentUser ->getUID () === $ cloud ->getUser () : false ;
198+ }
192199}
0 commit comments