update capabilities
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
This commit is contained in:
parent
5540def5e3
commit
676a4c781a
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
namespace OCA\Files_Sharing;
|
namespace OCA\Files_Sharing;
|
||||||
|
|
||||||
|
use OCP\App\IAppManager;
|
||||||
use OCP\Capabilities\ICapability;
|
use OCP\Capabilities\ICapability;
|
||||||
use \OCP\IConfig;
|
use \OCP\IConfig;
|
||||||
|
|
||||||
|
@ -34,8 +35,12 @@ class Capabilities implements ICapability {
|
||||||
/** @var IConfig */
|
/** @var IConfig */
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
public function __construct(IConfig $config) {
|
/** @var IAppManager */
|
||||||
|
private $appManager;
|
||||||
|
|
||||||
|
public function __construct(IConfig $config, IAppManager $appManager) {
|
||||||
$this->config = $config;
|
$this->config = $config;
|
||||||
|
$this->appManager = $appManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,16 +81,33 @@ class Capabilities implements ICapability {
|
||||||
$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
|
$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
|
||||||
|
|
||||||
$res['user']['send_mail'] = false;
|
$res['user']['send_mail'] = false;
|
||||||
|
$res['user']['expire_date']['enabled'] = true;
|
||||||
|
|
||||||
|
// deprecated in favour of 'group', but we need to keep it for now
|
||||||
|
// in order to stay compatible with older clients
|
||||||
$res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
|
$res['group_sharing'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
|
||||||
|
|
||||||
|
$res['group'] = [];
|
||||||
|
$res['group']['enabled'] = $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes') === 'yes';
|
||||||
|
$res['group']['expire_date']['enabled'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Federated sharing
|
//Federated sharing
|
||||||
$res['federation'] = [
|
$res['federation'] = [
|
||||||
'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes',
|
'outgoing' => $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'yes',
|
||||||
'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes'
|
'incoming' => $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'yes',
|
||||||
|
'expire_date' => ['enabled' => true]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if ($this->appManager->isEnabledForUser('sharebymail')) {
|
||||||
|
$res['mailshare'] = [
|
||||||
|
'enabled' => true,
|
||||||
|
'upload_files_drop' => ['enabled' => true],
|
||||||
|
'password' => ['enabled' => true],
|
||||||
|
'expire_date' => ['enabled' => true]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'files_sharing' => $res,
|
'files_sharing' => $res,
|
||||||
];
|
];
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace OCA\Files_Sharing\Tests;
|
||||||
|
|
||||||
use OCA\Files_Sharing\Capabilities;
|
use OCA\Files_Sharing\Capabilities;
|
||||||
use OCA\Files_Sharing\Tests\TestCase;
|
use OCA\Files_Sharing\Tests\TestCase;
|
||||||
|
use OCP\App\IAppManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CapabilitiesTest
|
* Class CapabilitiesTest
|
||||||
|
@ -46,7 +47,7 @@ class CapabilitiesTest extends \Test\TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a mock config object and insert the values in $map tot the getAppValue
|
* Create a mock config object and insert the values in $map to the getAppValue
|
||||||
* function. Then obtain the capabilities and extract the first few
|
* function. Then obtain the capabilities and extract the first few
|
||||||
* levels in the array
|
* levels in the array
|
||||||
*
|
*
|
||||||
|
@ -54,9 +55,11 @@ class CapabilitiesTest extends \Test\TestCase {
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function getResults(array $map) {
|
private function getResults(array $map) {
|
||||||
$stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock();
|
$config = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock();
|
||||||
$stub->method('getAppValue')->will($this->returnValueMap($map));
|
$config->method('getAppValue')->will($this->returnValueMap($map));
|
||||||
$cap = new Capabilities($stub);
|
$appManager = $this->getMockBuilder(IAppManager::class)->getMock();
|
||||||
|
$appManager->expects($this->any())->method('isEnabledForUser')->with('sharebymail')->willReturn(true);
|
||||||
|
$cap = new Capabilities($config, $appManager);
|
||||||
$result = $this->getFilesSharingPart($cap->getCapabilities());
|
$result = $this->getFilesSharingPart($cap->getCapabilities());
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue