aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Share20/Manager.php
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2020-12-30 00:48:01 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2021-03-22 06:50:47 +0100
commitf99876997a9119518fe5f7ad3a3a51d33459d4cc (patch)
tree46cc6604137a904f3b8b9eff8c226d713bd48ac1 /lib/private/Share20/Manager.php
parent0f3f6a6c54f492b6efe95aad15e9c4290bd4df6e (diff)
downloadnextcloud-server-f99876997a9119518fe5f7ad3a3a51d33459d4cc.tar.gz
nextcloud-server-f99876997a9119518fe5f7ad3a3a51d33459d4cc.zip
Remove duplicated query for email shares
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com> Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
Diffstat (limited to 'lib/private/Share20/Manager.php')
-rw-r--r--lib/private/Share20/Manager.php52
1 files changed, 18 insertions, 34 deletions
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index a0778319a7b..d021e57c4dc 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -740,25 +740,23 @@ class Manager implements IManager {
}
try {
- //Verify share type
+ // Verify share type
if ($share->getShareType() === IShare::TYPE_USER) {
$this->userCreateChecks($share);
- //Verify the expiration date
+ // Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
} elseif ($share->getShareType() === IShare::TYPE_GROUP) {
$this->groupCreateChecks($share);
- //Verify the expiration date
+ // Verify the expiration date
$share = $this->validateExpirationDateInternal($share);
} elseif ($share->getShareType() === IShare::TYPE_LINK
|| $share->getShareType() === IShare::TYPE_EMAIL) {
$this->linkCreateChecks($share);
$this->setLinkParent($share);
- /*
- * For now ignore a set token.
- */
+ // For now ignore a set token.
$share->setToken(
$this->secureRandom->generate(
\OC\Share\Constants::TOKEN_LENGTH,
@@ -767,7 +765,7 @@ class Manager implements IManager {
);
// Verify the expiration date
- $share = $this->validateExpirationDateLink($share);
+ $share = $this->validateExpirationDate($share);
// Verify the password
$this->verifyPassword($share->getPassword());
@@ -799,7 +797,8 @@ class Manager implements IManager {
$oldShare = $share;
$provider = $this->factory->getProviderForType($share->getShareType());
$share = $provider->create($share);
- //reuse the node we already have
+
+ // Reuse the node we already have
$share->setNode($oldShare->getNode());
// Reset the target if it is null for the new share
@@ -987,38 +986,23 @@ class Manager implements IManager {
|| $share->getShareType() === IShare::TYPE_EMAIL) {
$this->linkCreateChecks($share);
+ // The new password is not set again if it is the same as the old one.
$plainTextPassword = $share->getPassword();
- $this->updateSharePasswordIfNeeded($share, $originalShare);
-
- if (empty($plainTextPassword) && $share->getSendPasswordByTalk()) {
- throw new \InvalidArgumentException('Can’t enable sending the password by Talk with an empty password');
- }
-
- if ($share->getExpirationDate() != $originalShare->getExpirationDate()) {
- //Verify the expiration date
- $this->validateExpirationDateLink($share);
- $expirationDateUpdated = true;
- }
- } elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
- // The new password is not set again if it is the same as the old
- // one.
- $plainTextPassword = $share->getPassword();
- if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare)) {
- $plainTextPassword = null;
+ if (empty($plainTextPassword)) {
+ if (!$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) {
+ // If the same password was already sent by mail the recipient
+ // would already have access to the share without having to call
+ // the sharer to verify her identity
+ throw new \InvalidArgumentException('Can’t enable sending the password by Talk without setting a new password');
+ }
+ if ($originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk()) {
+ throw new \InvalidArgumentException('Can’t disable sending the password by Talk without setting a new password');
+ }
}
$this->updateSharePasswordIfNeeded($share, $originalShare);
- if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) {
- // If the same password was already sent by mail the recipient
- // would already have access to the share without having to call
- // the sharer to verify her identity
- throw new \InvalidArgumentException('Can’t enable sending the password by Talk without setting a new password');
- } elseif (empty($plainTextPassword) && $originalShare->getSendPasswordByTalk() && !$share->getSendPasswordByTalk()) {
- throw new \InvalidArgumentException('Can’t disable sending the password by Talk without setting a new password');
- }
-
if ($share->getExpirationDate() != $originalShare->getExpirationDate()) {
// Verify the expiration date
$this->validateExpirationDate($share);