Fix getting the information of a group share as a sharee #10046
Merged
+80
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the receiver of a group share modifies it (for example, by moving it to a different folder) the original share is not modified, but a "ghost" share that keeps track of the changes made by that specific user is used instead.
By default, the method
getShareByIdin the share provider returns the share from the point of view of the sharer, but it can be used too to get the share from the point of view of a sharee by providing therecipientparameter (and if the sharee is not found then the share is returned from the point of view of the sharer).The
ShareAPIControlleralways formats the share from the point of view of the current user, but when getting the information of a specific share therecipientparameter was not given, so it was always returned from the point of view of the sharer, even if the current user was a sharee. Now therecipientparameter is set to the current user, and thus the information of the share is returned from the point of view of the current user, be it the sharer or a sharee.All this can be seen in the integration tests added also in this pull request; without the fix, when getting the information of a group share as a sharee, the returned
file_targetis /textfile0.txt instead of /textfile0 (2).txt (because it is returned bygetShareById), but the returnedpathis /textfile0 (2).txt with and without the fix (because it is got from the node as the current user when the share is formatted).Note that this special behaviour of
getShareByIdhappens only with group shares; with other types of shares the share is the same for the sharer and the sharee, and thus the parameter is ignored (DefaultShareProvider,ShareByCircleProvider,ShareByMailProviderandFederatedShareProvider); it was added for them too just for consistency.