From e46c2b5ae2ad0fba9895942bd5fe8baa2272a545 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 8 Oct 2020 12:32:17 +0200 Subject: [PATCH 001/129] Only use numeric tokens for conversations when sip is configured Signed-off-by: Joas Schilling --- lib/Manager.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Manager.php b/lib/Manager.php index 5a4b81eb7cc..95a18b0484b 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -804,10 +804,18 @@ protected function getRoomNameByParticipants(Room $room): string { * @return string */ protected function getNewToken(): string { - $chars = str_replace(['l', '0', '1'], '', ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); + $sipConfig = $this->config->getAppValue('spreed', 'sip_config', ''); // FIXME adjust config name $entropy = (int) $this->config->getAppValue('spreed', 'token_entropy', 8); $entropy = max(8, $entropy); // For update cases + if ($sipConfig === '') { + $chars = str_replace(['l', '0', '1'], '', ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); + } else { + $chars = ISecureRandom::CHAR_DIGITS; + // Increase default token length as we only use numbers + $entropy = max(10, $entropy); + } + $query = $this->db->getQueryBuilder(); $query->select('id') ->from('talk_rooms') From 07adec8e9938be7f181ad3bb472deb3f52aa9bd6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 8 Oct 2020 14:28:01 +0200 Subject: [PATCH 002/129] Add a setting which groups can enable SIP in conversations Signed-off-by: Joas Schilling --- lib/Config.php | 9 ++ lib/Settings/Admin/AdminSettings.php | 5 + src/components/AdminSettings/SIPBridge.vue | 147 +++++++++++++++++++++ src/views/AdminSettings.vue | 19 +-- 4 files changed, 172 insertions(+), 8 deletions(-) create mode 100644 src/components/AdminSettings/SIPBridge.vue diff --git a/lib/Config.php b/lib/Config.php index 6f8abca7ccd..2fe9da2b207 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -62,6 +62,15 @@ public function getAllowedTalkGroupIds(): array { return \is_array($groups) ? $groups : []; } + /** + * @return string[] + */ + public function getSIPGroups(): array { + $groups = $this->config->getAppValue('spreed', 'sip_bridge_groups', '[]'); + $groups = json_decode($groups, true); + return \is_array($groups) ? $groups : []; + } + public function isDisabledForUser(IUser $user): bool { $allowedGroups = $this->getAllowedTalkGroupIds(); if (empty($allowedGroups)) { diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index 94b69e24649..725b2540f08 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -93,6 +93,7 @@ public function getForm(): TemplateResponse { $this->initTurnServers(); $this->initSignalingServers(); $this->initRequestSignalingServerTrial(); + $this->initSIPBridge(); return new TemplateResponse('spreed', 'settings/admin-settings', [], ''); } @@ -467,6 +468,10 @@ protected function initRequestSignalingServerTrial(): void { ]); } + protected function initSIPBridge(): void { + $this->initialStateService->provideInitialState('talk', 'sip_bridge_groups', $this->talkConfig->getSIPGroups()); + } + /** * @return string the section ID, e.g. 'sharing' */ diff --git a/src/components/AdminSettings/SIPBridge.vue b/src/components/AdminSettings/SIPBridge.vue new file mode 100644 index 00000000000..db90804c46e --- /dev/null +++ b/src/components/AdminSettings/SIPBridge.vue @@ -0,0 +1,147 @@ + + + + + + + diff --git a/src/views/AdminSettings.vue b/src/views/AdminSettings.vue index a3cc105e46a..095c7903b92 100644 --- a/src/views/AdminSettings.vue +++ b/src/views/AdminSettings.vue @@ -30,31 +30,34 @@ + From 208d4f965b6e5794d1bef8925537be7b1a930148 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 8 Oct 2020 16:33:13 +0200 Subject: [PATCH 003/129] Add dial-in info and fix group display names Signed-off-by: Joas Schilling --- lib/Config.php | 4 + lib/Settings/Admin/AdminSettings.php | 21 +++- src/components/AdminSettings/SIPBridge.vue | 119 ++++++++++++--------- 3 files changed, 90 insertions(+), 54 deletions(-) diff --git a/lib/Config.php b/lib/Config.php index 2fe9da2b207..ffbcc1fa8e5 100644 --- a/lib/Config.php +++ b/lib/Config.php @@ -71,6 +71,10 @@ public function getSIPGroups(): array { return \is_array($groups) ? $groups : []; } + public function getDialInInfo(): string { + return $this->config->getAppValue('spreed', 'sip_bridge_dial-in_info', ''); + } + public function isDisabledForUser(IUser $user): bool { $allowedGroups = $this->getAllowedTalkGroupIds(); if (empty($allowedGroups)) { diff --git a/lib/Settings/Admin/AdminSettings.php b/lib/Settings/Admin/AdminSettings.php index 725b2540f08..da2df2f6639 100644 --- a/lib/Settings/Admin/AdminSettings.php +++ b/lib/Settings/Admin/AdminSettings.php @@ -33,6 +33,8 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\ICacheFactory; use OCP\IConfig; +use OCP\IGroup; +use OCP\IGroupManager; use OCP\IInitialStateService; use OCP\IL10N; use OCP\IUser; @@ -52,6 +54,8 @@ class AdminSettings implements ISettings { private $initialStateService; /** @var ICacheFactory */ private $memcacheFactory; + /** @var IGroupManager */ + private $groupManager; /** @var MatterbridgeManager */ private $bridgeManager; /** @var IUser */ @@ -66,6 +70,7 @@ public function __construct(Config $talkConfig, CommandService $commandService, IInitialStateService $initialStateService, ICacheFactory $memcacheFactory, + IGroupManager $groupManager, MatterbridgeManager $bridgeManager, IUserSession $userSession, IL10N $l10n, @@ -75,6 +80,7 @@ public function __construct(Config $talkConfig, $this->commandService = $commandService; $this->initialStateService = $initialStateService; $this->memcacheFactory = $memcacheFactory; + $this->groupManager = $groupManager; $this->bridgeManager = $bridgeManager; $this->currentUser = $userSession->getUser(); $this->l10n = $l10n; @@ -469,7 +475,20 @@ protected function initRequestSignalingServerTrial(): void { } protected function initSIPBridge(): void { - $this->initialStateService->provideInitialState('talk', 'sip_bridge_groups', $this->talkConfig->getSIPGroups()); + $gids = $this->talkConfig->getSIPGroups(); + $groups = []; + foreach ($gids as $gid) { + $group = $this->groupManager->get($gid); + if ($group instanceof IGroup) { + $groups[] = [ + 'id' => $group->getGID(), + 'displayname' => $group->getDisplayName(), + ]; + } + } + + $this->initialStateService->provideInitialState('talk', 'sip_bridge_groups', $groups); + $this->initialStateService->provideInitialState('talk', 'sip_bridge_dial-in_info', $this->talkConfig->getDialInInfo()); } /** diff --git a/src/components/AdminSettings/SIPBridge.vue b/src/components/AdminSettings/SIPBridge.vue index db90804c46e..56f2064b19c 100644 --- a/src/components/AdminSettings/SIPBridge.vue +++ b/src/components/AdminSettings/SIPBridge.vue @@ -21,31 +21,48 @@ -->