-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Splits off the logic from sharees endpoint thus making it available from within Nc/via PHP. #6328
Conversation
@blizzz, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nickvergessen, @rullzer and @schiessle to be potential reviewers. |
could be fun to merge with #5280 |
on first glance, i did not see conflict potential. different controller and endpoint. |
5c7de25
to
c97ca38
Compare
Codecov Report
@@ Coverage Diff @@
## master #6328 +/- ##
============================================
+ Coverage 53.06% 55.57% +2.51%
+ Complexity 22570 21264 -1306
============================================
Files 1417 1261 -156
Lines 87810 73270 -14540
Branches 1340 0 -1340
============================================
- Hits 46597 40723 -5874
+ Misses 41213 32547 -8666
|
use OCP\Collaboration\Collaborators\ISearchPlugin; | ||
use OCP\Collaboration\Collaborators\ISearchResult; | ||
|
||
class CirclePlugin implements ISearchPlugin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be provided by the circles app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, then I need to add a register method and such… or another entry for the appinfo xml file… not much of a big deal, of course, I was hoping to get around this. After all, it's "just" axe sharpening for the autocomplete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The annoying part here is the shareType. The client needs to request the shareTypes as they are define in \OC\Share\Constants (made available via \OCP\Share). This makes it hard to register new share types for apps, and even harder for clients for figuring out new features. OTOH all the types may have special aspects themselves, so special treatment might be necessary nevertheless.
That said, what makes most sense to me is to allow registering plugins for existing share types. And opening this for 1:x relationships (one type, many plugins).
$result['wide'] = []; | ||
} | ||
|
||
if (!$searchResult->hasExactIdMatch('emails') && filter_var($search, FILTER_VALIDATE_EMAIL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also not be done, when remote sharing has an exact match and vice-versa.
See old line 567 of the ShareesController code.
What would be the best to achive this? Or where is this done now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah it's in the Search class now, all good
'groups' => [], | ||
'remotes' => [], | ||
'emails' => [], | ||
'circles' => [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I somewhat dislike this. Would be nicer if this is kept modular and provided by each app
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, yes, I am not sure which side effects this might have for consumers of the endpoint.
OTOH it's better to risk a bug there now, than carrying cruft forever with us. I have a look at it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, i could simply merge it into the existing results array in the controller to preserver the state there, and have it leaner in the new impl.
Nice cleanup, I always disliked the naming anyway. |
From within cire, pointing to the files_sharing controller? It might be disabled… We could move this, too, or think about a new Controller in the server… but this I see in a follow-up PR, rather. |
required for nextcloud/server#6328 Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
@nickvergessen so I moved the Circles plugin to its own app (nextcloud/circles#126) → registering Plugins works. Also, the result types are not fixed but filled by the plugins. I added a public class for this to have type name validated. The LookupPlugin might go to the Also, the MailPlugin can go to 'sharebymail' app, unless something speaks against it ( @schiessle ?), and the RemotePlugin to 'federation'. |
throw new \InvalidArgumentException('Type must not be empty'); | ||
} | ||
|
||
if(trim($type) === 'exact') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trim is not necessary, you do it in the beginning already
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was a leftover when i was pushing code around… thanks for pointing that out 👈 👍
Now 🤹 with the ShareeAPIController unit tests was exciting 💤 ;) |
@@ -159,6 +159,6 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) { | |||
|
|||
$searchResult->addResultSet($emailType, $result['wide'], $result['exact']); | |||
|
|||
return false; | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schiessle this (= always more results available) feels wrong, but was required due to the unit tests. Or did I oversee anything?
@@ -116,7 +116,7 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) { | |||
|
|||
$searchResult->addResultSet($resultType, $result['wide'], $result['exact']); | |||
|
|||
return false; | |||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@schiessle this (= always more results available) feels wrong, but was required due to the unit tests. Or did I oversee anything?
4ff9aec
to
82c8193
Compare
I kept LookupPlugin inside lib/…, because it is involved differently for whatever reason (invocation by explicit flag, not ShareType). Since there is no dedicated ShareType, I refrain to change this. This said, I'd be happy about final reviews 😸 |
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
adds two small fixes → they actually work \o/ Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
also moves registering default plugins to Server for proper unit testing Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
82c8193
to
937a80c
Compare
due to requests from @nickvergessen and @BernhardPosselt i simplified the required XML. OK now? Needs green lights on nextcloud/appstore#521, too. |
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Codecov Report
@@ Coverage Diff @@
## master #6328 +/- ##
============================================
+ Coverage 53.06% 53.09% +0.03%
- Complexity 22570 22594 +24
============================================
Files 1417 1425 +8
Lines 87810 87889 +79
Branches 1340 1340
============================================
+ Hits 46597 46668 +71
- Misses 41213 41221 +8
|
🏓 |
Looks good and still works, but: current user is returned (was not the case before). |
Okay lets do it in a follow up |
$emailAddresses = [$emailAddresses]; | ||
} | ||
foreach ($emailAddresses as $emailAddress) { | ||
$exactEmailMatch = strtolower($emailAddress) === $lowerSearch; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took it over as it is from the old method and have not spotted a post processing that would remove it. Thus, it should be reproducable with the old code I think… anyhow, yes, something we should fix
@schiessle as discussed yesterday. Took a bit more effort, because i decided to split off the different getters to Plugins. However, I did not create a register function or anything. Can be added later if it becomes necessary. Right now, I doubt this and want to keep effort small. I did not touch tests, yet, however Smoke tests with the share dialog worked for me. Are you OK with that approach?
necessary for #2443
P.S.: Context: @schiessle prefered to have the logic outside of the Sharing scope, due to his concern that a universal API is established again. Therefore we thought the Collaborator terminology could fit.