-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New share provider: Share by mail #657
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0a6f028
introduce share by mail, ui part
schiessle a17c6a4
add share by mail share provider
schiessle 96c40d1
update permissions
schiessle 3181606
add method to check if a share provider for a given type is loaded
schiessle 77f74b9
handle case if no share-by-mail share provider is loaded
schiessle 60a3893
improve search for federated cloud ids and email adresses
schiessle 8c8a019
show correct display name if we have the user in one of our address b…
schiessle 392c8a1
unified way to display remote shares and mail shares
schiessle 7436e45
if we have a exact match, either for the federated cloud id or for the
schiessle 31c8c38
send mail for share-by-mail shares
schiessle 561dd80
don't show 'notify by mail' option or permissions not available for m…
schiessle 1e930df
find and show share-by mail links
schiessle 6d7520b
unit tests updated and new added
schiessle ce08682
enabled by default and add to shipped.json
schiessle 86b3628
always show correct place holder, mention share by mail only if the s…
schiessle 16ec0f2
add tests for the share-by-mail provider
schiessle 32dbf32
add new method getSharesInFolder(), see #339
schiessle 6e52091
remove unused variable
schiessle f2b2b8d
import exception
schiessle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,6 @@ | |
| use OCP\IUserManager; | ||
| use OCP\IRequest; | ||
| use OCP\IURLGenerator; | ||
| use OCP\IUser; | ||
| use OCP\Files\IRootFolder; | ||
| use OCP\Lock\LockedException; | ||
| use OCP\Share\IManager; | ||
|
|
@@ -186,7 +185,11 @@ protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = n | |
|
|
||
| } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_REMOTE) { | ||
| $result['share_with'] = $share->getSharedWith(); | ||
| $result['share_with_displayname'] = $share->getSharedWith(); | ||
| $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'CLOUD'); | ||
| $result['token'] = $share->getToken(); | ||
| } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_EMAIL) { | ||
| $result['share_with'] = $share->getSharedWith(); | ||
| $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL'); | ||
| $result['token'] = $share->getToken(); | ||
| } | ||
|
|
||
|
|
@@ -195,6 +198,28 @@ protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = n | |
| return $result; | ||
| } | ||
|
|
||
| /** | ||
| * Check if one of the users address books knows the exact property, if | ||
| * yes we return the full name. | ||
| * | ||
| * @param string $query | ||
| * @param string $property | ||
| * @return string | ||
| */ | ||
| private function getDisplayNameFromAddressBook($query, $property) { | ||
| // FIXME: If we inject the contacts manager it gets initialized bofore any address books are registered | ||
| $result = \OC::$server->getContactsManager()->search($query, [$property]); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmm we should find a nice solution for that. But for now I guess it is OK |
||
| foreach ($result as $r) { | ||
| foreach($r[$property] as $value) { | ||
| if ($value === $query) { | ||
| return $r['FN']; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return $query; | ||
| } | ||
|
|
||
| /** | ||
| * Get a specific share by id | ||
| * | ||
|
|
@@ -400,6 +425,17 @@ public function createShare( | |
|
|
||
| $share->setSharedWith($shareWith); | ||
| $share->setPermissions($permissions); | ||
| } else if ($shareType === \OCP\Share::SHARE_TYPE_EMAIL) { | ||
| if ($share->getNodeType() === 'file') { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for myself to change this for #1836 |
||
| $share->setPermissions(\OCP\Constants::PERMISSION_READ); | ||
| } else { | ||
| $share->setPermissions( | ||
| \OCP\Constants::PERMISSION_READ | | ||
| \OCP\Constants::PERMISSION_CREATE | | ||
| \OCP\Constants::PERMISSION_UPDATE | | ||
| \OCP\Constants::PERMISSION_DELETE); | ||
| } | ||
| $share->setSharedWith($shareWith); | ||
| } else { | ||
| throw new OCSBadRequestException($this->l->t('Unknown share type')); | ||
| } | ||
|
|
@@ -466,6 +502,9 @@ private function getSharesInDir($folder) { | |
| $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $node, false, -1, 0)); | ||
| $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $node, false, -1, 0)); | ||
| $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $node, false, -1, 0)); | ||
| if($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { | ||
| $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $node, false, -1, 0)); | ||
| } | ||
| if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { | ||
| $shares = array_merge($shares, $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $node, false, -1, 0)); | ||
| } | ||
|
|
@@ -541,7 +580,12 @@ public function getShares( | |
| $userShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_USER, $path, $reshares, -1, 0); | ||
| $groupShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_GROUP, $path, $reshares, -1, 0); | ||
| $linkShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_LINK, $path, $reshares, -1, 0); | ||
| $shares = array_merge($userShares, $groupShares, $linkShares); | ||
| if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { | ||
| $mailShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_EMAIL, $path, $reshares, -1, 0); | ||
| } else { | ||
| $mailShares = []; | ||
| } | ||
| $shares = array_merge($userShares, $groupShares, $linkShares, $mailShares); | ||
|
|
||
| if ($this->shareManager->outgoingServer2ServerSharesAllowed()) { | ||
| $federatedShares = $this->shareManager->getSharesBy($this->currentUser, \OCP\Share::SHARE_TYPE_REMOTE, $path, $reshares, -1, 0); | ||
|
|
@@ -774,13 +818,24 @@ private function getShareById($id) { | |
| // First check if it is an internal share. | ||
| try { | ||
| $share = $this->shareManager->getShareById('ocinternal:' . $id); | ||
| return $share; | ||
| } catch (ShareNotFound $e) { | ||
| if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { | ||
| throw new ShareNotFound(); | ||
| // Do nothing, just try the other share type | ||
| } | ||
|
|
||
| try { | ||
| if ($this->shareManager->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { | ||
| $share = $this->shareManager->getShareById('ocMailShare:' . $id); | ||
| return $share; | ||
| } | ||
| } catch (ShareNotFound $e) { | ||
| // Do nothing, just try the other share type | ||
| } | ||
|
|
||
| $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id); | ||
| if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) { | ||
| throw new ShareNotFound(); | ||
| } | ||
| $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id); | ||
|
|
||
| return $share; | ||
| } | ||
|
|
||
Oops, something went wrong.
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.
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 alphabetic order
Uh oh!
There was an error while loading. Please reload this page.
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 other entries are also not in alphabetic order