Skip to content
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

Implement share co-owning #49073

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

provokateurin
Copy link
Member

@provokateurin provokateurin commented Nov 4, 2024

Summary

Can be tested with nextcloud/groupfolders#3401

Tests still need to be written, but other than that this is ready.
It doesn't work with files_external yet, but I think that is due to permissions (UI says there is no reshare permission).

I'm surprised how little lines had to be changed in the end, but the challenging part was exploring how this can be implemented and where things needs to be changed and fixed to make it work.

Behavior:

  • If the owner is deleted the shares will be deleted
  • If the owner is disabled the shares continue to exist
  • If the owner loses access (e.g. removed from group that had access to the Groupfolder) the shares will be deleted

Checklist

$shares = [];
foreach ($providers as $provider) {
if ($isCoOwner) {
foreach ($node->getDirectoryListing() as $childNode) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes it a lot more expensive, can we tweak getSharesInFolder to make the $user filter optional instead?

Copy link
Member Author

@provokateurin provokateurin Nov 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do this without a breaking change, as it would break provider implementations that don't expect to receive null.
Maybe that is fine though, as long as the providers only do database SELECTs where a null value is fine (but that would still result in unexpected results as nothing would be returned instead of everything).

@provokateurin provokateurin requested review from a team, ArtificialOwl, icewind1991 and come-nc and removed request for a team November 13, 2024 13:45
@provokateurin provokateurin marked this pull request as ready for review November 13, 2024 13:45
@provokateurin
Copy link
Member Author

Added tests for everything 🎉

@provokateurin provokateurin added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Nov 13, 2024
@provokateurin provokateurin force-pushed the feat/files_sharing/co-owner branch 2 times, most recently from 58b9fb5 to 4c63eba Compare November 13, 2024 13:51
@@ -78,6 +78,11 @@ export default {
} else if (this.share.type === this.SHARE_TYPES.SHARE_TYPE_GUEST) {
title += ` (${t('files_sharing', 'guest')})`
}
if (!this.isShareOwner && this.share.ownerDisplayName) {
title += t('files_sharing', ' by {initiator}', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leading / trailing spaces in translations are very likely to break

Suggested change
title += t('files_sharing', ' by {initiator}', {
title += ' ' + t('files_sharing', 'by {initiator}', {

// Ignore share, file is still accessible
} catch (NotFoundException) {
// Access lost
$this->deleteShare($share);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can lead to data loss, e.g. external storage that is temporarily not available.

@@ -1553,6 +1542,12 @@ protected function canEditShare(IShare $share): bool {
return true;
}

$userFolder = $this->rootFolder->getUserFolder($this->userId);
$file = $userFolder->getFirstNodeById($share->getNodeId());
if ($file !== null && $file->getMountPoint() instanceof IShareCoOwnerMount && $this->shareProviderResharingRights($this->userId, $share, $file)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe if ($file?->getMountPoint() instanceof [...]) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants