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

Add support for sending the password for a link share by Nextcloud Talk #11875

20 changes: 20 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = n
$result['share_with'] = $share->getPassword();
$result['share_with_displayname'] = $share->getPassword();

$result['send_password_by_talk'] = $share->getSendPasswordByTalk();

$result['token'] = $share->getToken();
$result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);

Expand Down Expand Up @@ -477,10 +479,19 @@ public function createShare(
$share->setPassword($password);
}


if (!empty($label)) {
$share->setLabel($label);
}

if ($sendPasswordByTalk === 'true') {
if (!$this->appManager->isEnabledForUser('spreed')) {
throw new OCSForbiddenException($this->l->t('Sharing %s sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled', [$path->getPath()]));
}

$share->setSendPasswordByTalk(true);
}

//Expire date
if ($expireDate !== '') {
try {
Expand Down Expand Up @@ -873,6 +884,15 @@ public function updateShare(
$share->setLabel($label);
}

if ($sendPasswordByTalk === 'true') {
if (!$this->appManager->isEnabledForUser('spreed')) {
throw new OCSForbiddenException($this->l->t('Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled'));
}

$share->setSendPasswordByTalk(true);
} else if ($sendPasswordByTalk !== null) {
$share->setSendPasswordByTalk(false);
}
} else {
if ($permissions !== null) {
$permissions = (int)$permissions;
Expand Down
Loading