@@ -97,13 +97,17 @@ protected function dropMailSharesWhereRemoteShareIsPossible(ISearchResult $searc
9797 $ emailType = new SearchResultType ('emails ' );
9898 $ remoteType = new SearchResultType ('remotes ' );
9999
100- if (!isset ($ allResults [$ remoteType ->getLabel ()])
101- || !isset ($ allResults [$ emailType ->getLabel ()])) {
100+ $ emailLabel = $ emailType ->getLabel ();
101+ $ emailEntries = array_merge (
102+ $ allResults ['exact ' ][$ emailLabel ] ?? [],
103+ $ allResults [$ emailLabel ] ?? []
104+ );
105+ if ($ emailEntries === []) {
102106 return ;
103107 }
104108
105109 $ mailIdMap = [];
106- foreach ($ allResults [ $ emailType -> getLabel ()] as $ mailRow ) {
110+ foreach ($ emailEntries as $ mailRow ) {
107111 // sure, array_reduce looks nicer, but foreach needs less resources and is faster
108112 if (!isset ($ mailRow ['uuid ' ])) {
109113 continue ;
@@ -119,5 +123,17 @@ protected function dropMailSharesWhereRemoteShareIsPossible(ISearchResult $searc
119123 $ searchResult ->removeCollaboratorResult ($ emailType , $ mailIdMap [$ resultRow ['uuid ' ]]);
120124 }
121125 }
126+ $ lookupType = new SearchResultType ('lookup ' );
127+ if (isset ($ allResults [$ lookupType ->getLabel ()])) {
128+ foreach ($ allResults [$ lookupType ->getLabel ()] as $ resultRow ) {
129+ $ userid = $ resultRow ['extra ' ]['userid ' ]['value ' ] ?? null ;
130+ if ($ userid === null ) {
131+ continue ;
132+ }
133+ if (isset ($ mailIdMap [$ userid ])) {
134+ $ searchResult ->removeCollaboratorResult ($ emailType , $ mailIdMap [$ userid ]);
135+ }
136+ }
137+ }
122138 }
123139}
0 commit comments