-
-
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
enh: Show remote shares in external section #51312
base: master
Are you sure you want to change the base?
Conversation
Improve the OCS files sharing API to include a share type filter in `getShares` Signed-off-by: nfebe <[email protected]>
Signed-off-by: nfebe <[email protected]>
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.
Not sure we need two requests to the backend, we also can just filter on the frontend
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.
Agreed, the filtering should be done on the frontend.
Also this breaks other API users because you introduce a new field without a default value that is the same as the current behavior.
I think having this in the API is necessary. An API that returns different types of shares should naturally support filtering by type. Beyond this specific use case, I’m actually surprised that this wasn’t already possible in the cc: @susnux
That is not true. This change is not a breaking change. Omitting the parameter results in the current behavior, returning all shares as expected. Internal and external apps will continue to function as before. cc: @provokateurin Generally, this increases performance, especially for instances/users with a sizable number of shares, Splitting and parallelizing the request has clear benefits and some drawbacks and so does frontend filtering. The new new API option/field, is a valuable addition because asides giving the client more flexibility it does not change current behavior, as long as it gets into the |
I am not sure here.
So I do not see any benefit here as the shares are requested the same way, there is no shortcut taken while fetching the shares, only formatting them is skipped. But this means now we have two fetch all shares 2 times iterate overthem and filter them. |
With the types filter in place (1e7f53e) we should avoid, fetching all shares. Preventing potential N+1s Signed-off-by: nfebe <[email protected]>
6339447
to
cca22cb
Compare
If making two requests results to smaller response sizes then, it is generally faster. The different components can render as the data is available.
This is a legitimate concern, I have added a commit to avoid fetching ALL shares, as the method that does it sequentially iterates over all the providers, if we simply pass the types (providers) to this method, then it stops most of this problem. server/apps/files_sharing/lib/Controller/ShareAPIController.php Lines 1872 to 1880 in bb6b462
The issue of more requests -> more server load remains nonetheless this kind of filtering is usually handled at the backend and even we do not want to use it here, I still think it is essential that shares can be filtered by type. cc: @susnux |
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 am aware of the missing openapi update, had some issues with composer exec generate-spec
.
While the main reviews are being cleared that would be handled.
I'm mostly siding with @susnux here and my previous comments were under the assumption that the providers were told which share types to query (because I didn't look at the code further). |
$types = array_map('intval', $types); | ||
foreach ($types as $type) { | ||
match ($type) { | ||
IShare::TYPE_USER, | ||
IShare::TYPE_GROUP, | ||
IShare::TYPE_LINK, | ||
IShare::TYPE_EMAIL, | ||
IShare::TYPE_REMOTE, | ||
IShare::TYPE_REMOTE_GROUP, | ||
IShare::TYPE_CIRCLE, | ||
IShare::TYPE_ROOM, | ||
IShare::TYPE_DECK, | ||
IShare::TYPE_SCIENCEMESH => null, | ||
default => throw new OCSBadRequestException( | ||
$this->l->t('Cannot filter by unknown share types') | ||
), | ||
}; | ||
} |
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.
Please do array_filter instead and check if the result is not empty. If the match just returns true/false it's good, but using it like this is not a great idea.
Description
feat(files_sharing): Add types filter to getShares
feat(sharing_tab): Show remote shares in external shares section
Screenshots
Resolves : #51226