diff options
author | Joas Schilling <coding@schilljs.com> | 2019-06-27 19:07:08 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-06-27 19:07:08 +0300 |
commit | 86164d4838a7f2d0102b4bd68f18ceab0bb04a93 (patch) | |
tree | a4fb803a70f2e29daed36ff2d10ec6b2763cb058 /lib/Capabilities.php | |
parent | 0fb7a8cb1991c0673cf3a3a5e59a1f502dfe03e0 (diff) |
Add a capability
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Capabilities.php')
-rw-r--r-- | lib/Capabilities.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/Capabilities.php b/lib/Capabilities.php index f26437945..4fb5149b7 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -24,29 +24,40 @@ declare(strict_types=1); namespace OCA\Spreed; +use OCA\Spreed\Chat\ChatManager; use OCP\Capabilities\IPublicCapability; +use OCP\IConfig; use OCP\IUser; use OCP\IUserSession; class Capabilities implements IPublicCapability { + /** @var IConfig */ + protected $serverConfig; /** @var Config */ - protected $config; + protected $talkConfig; /** @var IUserSession */ protected $userSession; - public function __construct(Config $config, + public function __construct(IConfig $serverConfig, + Config $talkConfig, IUserSession $userSession) { - $this->config = $config; + $this->serverConfig = $serverConfig; + $this->talkConfig = $talkConfig; $this->userSession = $userSession; } public function getCapabilities(): array { $user = $this->userSession->getUser(); - if ($user instanceof IUser && $this->config->isDisabledForUser($user)) { + if ($user instanceof IUser && $this->talkConfig->isDisabledForUser($user)) { return []; } + $maxChatLength = 1000; + if (version_compare($this->serverConfig->getSystemValueString('version', '0.0.0'), '16.0.2', '>=')) { + $maxChatLength = ChatManager::MAX_CHAT_LENGTH; + } + return [ 'spreed' => [ 'features' => [ @@ -68,6 +79,11 @@ class Capabilities implements IPublicCapability { 'locked-one-to-one-rooms', 'read-only-rooms', ], + 'config' => [ + 'chat' => [ + 'max-length' => $maxChatLength, + ], + ], ], ]; } |