diff options
author | Joas Schilling <coding@schilljs.com> | 2020-10-14 15:17:12 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-10-30 12:38:07 +0300 |
commit | f76a2add671f812ea778936aa149b2e4072acc6e (patch) | |
tree | 3ed88b55cdcf4cfdbd7adf0b1ebe313e51ba99f3 /lib | |
parent | 845c53faefebc8702d81c4435fc301f220177f1a (diff) |
Add a shared secret
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Config.php | 6 | ||||
-rw-r--r-- | lib/Controller/SettingsController.php | 32 | ||||
-rw-r--r-- | lib/Settings/Admin/AdminSettings.php | 1 |
3 files changed, 38 insertions, 1 deletions
diff --git a/lib/Config.php b/lib/Config.php index ffbcc1fa8..0b77abdbc 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -72,7 +72,11 @@ class Config { } public function getDialInInfo(): string { - return $this->config->getAppValue('spreed', 'sip_bridge_dial-in_info', ''); + return $this->config->getAppValue('spreed', 'sip_bridge_dial-in_info'); + } + + public function getSIPSharedSecret(): string { + return $this->config->getAppValue('spreed', 'sip_bridge_shared_secret'); } public function isDisabledForUser(IUser $user): bool { diff --git a/lib/Controller/SettingsController.php b/lib/Controller/SettingsController.php index 1124456e5..2de96ae5d 100644 --- a/lib/Controller/SettingsController.php +++ b/lib/Controller/SettingsController.php @@ -34,6 +34,8 @@ use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OCP\IConfig; +use OCP\IGroup; +use OCP\IGroupManager; use OCP\IRequest; use Psr\Log\LoggerInterface; @@ -43,6 +45,8 @@ class SettingsController extends OCSController { protected $rootFolder; /** @var IConfig */ protected $config; + /** @var IGroupManager */ + protected $groupManager; /** @var LoggerInterface */ protected $logger; /** @var string|null */ @@ -52,11 +56,13 @@ class SettingsController extends OCSController { IRequest $request, IRootFolder $rootFolder, IConfig $config, + IGroupManager $groupManager, LoggerInterface $logger, ?string $userId) { parent::__construct($appName, $request); $this->rootFolder = $rootFolder; $this->config = $config; + $this->groupManager = $groupManager; $this->logger = $logger; $this->userId = $userId; } @@ -99,4 +105,30 @@ class SettingsController extends OCSController { return false; } + + /** + * @param string[] $sipGroups + * @param string $dialInInfo + * @param string $sharedSecret + * @return DataResponse + */ + public function setSIPSettings( + array $sipGroups = [], + string $dialInInfo = '', + string $sharedSecret = ''): DataResponse { + + $groups = []; + foreach ($sipGroups as $gid) { + $group = $this->groupManager->get($gid); + if ($group instanceof IGroup) { + $groups[] = $group->getGID(); + } + } + + $this->config->setAppValue('spreed', 'sip_bridge_groups', json_encode($groups)); + $this->config->setAppValue('spreed', 'sip_bridge_dial-in_info', $dialInInfo); + $this->config->setAppValue('spreed', 'sip_bridge_shared_secret', $sharedSecret); + + return new DataResponse(); + } } diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index da2df2f66..1bf2fa62d 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -488,6 +488,7 @@ class AdminSettings implements ISettings { } $this->initialStateService->provideInitialState('talk', 'sip_bridge_groups', $groups); + $this->initialStateService->provideInitialState('talk', 'sip_bridge_shared_secret', $this->talkConfig->getSIPSharedSecret()); $this->initialStateService->provideInitialState('talk', 'sip_bridge_dial-in_info', $this->talkConfig->getDialInInfo()); } |