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

Get access list share by email recipients #32631

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions apps/sharebymail/lib/ShareByMailProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1098,21 +1098,32 @@ public function getAccessList($nodes, $currentAccess): array {
}

$qb = $this->dbConnection->getQueryBuilder();
$qb->select('share_with')
$qb->select('share_with', 'file_source', 'token')
->from('share')
->where($qb->expr()->eq('share_type', $qb->createNamedParameter(IShare::TYPE_EMAIL)))
->andWhere($qb->expr()->in('file_source', $qb->createNamedParameter($ids, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($qb->expr()->orX(
$qb->expr()->eq('item_type', $qb->createNamedParameter('file')),
$qb->expr()->eq('item_type', $qb->createNamedParameter('folder'))
))
->setMaxResults(1);
));
$cursor = $qb->executeQuery();

$mail = $cursor->fetch() !== false;
$public = false;
$mail = [];
while ($row = $cursor->fetch()) {
$public = true;
if ($currentAccess === false) {
$mail[] = $row['share_with'];
} else {
$mail[$row['share_with']] = [
'node_id' => $row['file_source'],
'token' => $row['token']
];
}
}
$cursor->closeCursor();

return ['public' => $mail];
return ['public' => $public, 'mail' => $mail];
}

public function getAllShares(): iterable {
Expand Down
14 changes: 9 additions & 5 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1672,9 +1672,10 @@ public function userDeletedFromGroup($uid, $gid) {
* |-folder2 (32)
* |-fileA (42)
*
* fileA is shared with user1 and user1@server1
* fileA is shared with user1 and user1@server1 and email1@maildomain1
* folder2 is shared with group2 (user4 is a member of group2)
* folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
* and email2@maildomain2
*
* Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
* [
Expand All @@ -1688,15 +1689,18 @@ public function userDeletedFromGroup($uid, $gid) {
* 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
* ],
* public => bool
* mail => bool
* mail => [
* 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'],
* 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'],
* ]
* ]
*
* The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
* [
* users => ['user1', 'user2', 'user4'],
* remote => bool,
* public => bool
* mail => bool
* mail => ['email1@maildomain1', 'email2@maildomain2']
* ]
*
* This is required for encryption/activity
Expand All @@ -1716,9 +1720,9 @@ public function getAccessList(\OCP\Files\Node $path, $recursive = true, $current
$owner = $owner->getUID();

if ($currentAccess) {
$al = ['users' => [], 'remote' => [], 'public' => false];
$al = ['users' => [], 'remote' => [], 'public' => false, 'mail' => []];
} else {
$al = ['users' => [], 'remote' => false, 'public' => false];
$al = ['users' => [], 'remote' => false, 'public' => false, 'mail' => []];
}
if (!$this->userManager->userExists($owner)) {
return $al;
Expand Down
11 changes: 7 additions & 4 deletions lib/public/Share/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,10 @@ public function userDeletedFromGroup($uid, $gid);
* |-folder2 (32)
* |-fileA (42)
*
* fileA is shared with user1 and user1@server1
* fileA is shared with user1 and user1@server1 and email1@maildomain1
* folder2 is shared with group2 (user4 is a member of group2)
* folder1 is shared with user2 (renamed to "folder (1)") and user2@server2
* and email2@maildomain2
*
* Then the access list to '/folder1/folder2/fileA' with $currentAccess is:
* [
Expand All @@ -272,15 +273,17 @@ public function userDeletedFromGroup($uid, $gid);
* 'user2@server2' => ['node_id' => 23, 'token' => 'FooBaR'],
* ],
* public => bool
* mail => bool
* ]
* mail => [
* 'email1@maildomain1' => ['node_id' => 42, 'token' => 'aBcDeFg'],
* 'email2@maildomain2' => ['node_id' => 23, 'token' => 'hIjKlMn'],
* ]
*
* The access list to '/folder1/folder2/fileA' **without** $currentAccess is:
* [
* users => ['user1', 'user2', 'user4'],
* remote => bool,
* public => bool
* mail => bool
* mail => ['email1@maildomain1', 'email2@maildomain2']
Copy link
Member

Choose a reason for hiding this comment

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

this is an api break :( not sure if we can change this, but if it never worked it's probably fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it certainly is an API break. I went through the history and it never actually used the correct array key.

* ]
*
* This is required for encryption/activity
Expand Down
Loading