зеркало из https://github.com/nextcloud/spreed.git
Add a shared secret
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Родитель
845c53faef
Коммит
f76a2add67
|
@ -495,8 +495,16 @@ return [
|
|||
],
|
||||
|
||||
/**
|
||||
* UserSettings
|
||||
* Settings
|
||||
*/
|
||||
[
|
||||
'name' => 'Settings#setSIPSettings',
|
||||
'url' => '/api/{apiVersion}/settings/sip',
|
||||
'verb' => 'POST',
|
||||
'requirements' => [
|
||||
'apiVersion' => 'v1',
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'Settings#setUserSetting',
|
||||
'url' => '/api/{apiVersion}/settings/user',
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,11 @@
|
|||
-->
|
||||
|
||||
<template>
|
||||
<div id="sip-bridge" class="videocalls section">
|
||||
<div id="sip-bridge" class="section">
|
||||
<h2>{{ t('spreed', 'SIP configuration') }}</h2>
|
||||
|
||||
<h3>{{ t('spreed', 'Restrict SIP configuration') }}</h3>
|
||||
|
||||
<p class="settings-hint">
|
||||
{{ t('spreed', 'Only users of the following groups can enable SIP in conversations they moderate') }}
|
||||
</p>
|
||||
|
@ -44,6 +46,16 @@
|
|||
label="displayname"
|
||||
@search-change="searchGroup" />
|
||||
|
||||
<h3>{{ t('spreed', 'Shared secret') }}</h3>
|
||||
|
||||
<input v-model="sharedSecret"
|
||||
type="text"
|
||||
name="shared-secret"
|
||||
class="sip-bridge__shared-secret"
|
||||
:disabled="loading"
|
||||
:placeholder="t('spreed', 'Shared secret')"
|
||||
:aria-label="t('spreed', 'Shared secret')">
|
||||
|
||||
<h3>{{ t('spreed', 'Dial-in information') }}</h3>
|
||||
|
||||
<p class="settings-hint">
|
||||
|
@ -74,6 +86,7 @@ import axios from '@nextcloud/axios'
|
|||
import debounce from 'debounce'
|
||||
import { generateOcsUrl } from '@nextcloud/router'
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
import { setSIPSettings } from '../../services/settingsService'
|
||||
|
||||
export default {
|
||||
name: 'SIPBridge',
|
||||
|
@ -90,6 +103,7 @@ export default {
|
|||
sipGroups: [],
|
||||
saveLabel: t('spreed', 'Save changes'),
|
||||
dialInInfo: '',
|
||||
sharedSecret: '',
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -100,6 +114,7 @@ export default {
|
|||
})
|
||||
this.sipGroups = this.groups
|
||||
this.dialInInfo = loadState('talk', 'sip_bridge_dial-in_info')
|
||||
this.sharedSecret = loadState('talk', 'sip_bridge_shared_secret')
|
||||
this.searchGroup('')
|
||||
this.loading = false
|
||||
},
|
||||
|
@ -123,7 +138,7 @@ export default {
|
|||
}
|
||||
}, 500),
|
||||
|
||||
saveSIPSettings() {
|
||||
async saveSIPSettings() {
|
||||
this.loading = true
|
||||
this.saveLabel = t('spreed', 'Saving …')
|
||||
|
||||
|
@ -131,19 +146,13 @@ export default {
|
|||
return group.id
|
||||
})
|
||||
|
||||
OCP.AppConfig.setValue('spreed', 'sip_bridge_groups', JSON.stringify(groups), {
|
||||
success: () => {
|
||||
OCP.AppConfig.setValue('spreed', 'sip_bridge_dial-in_info', this.dialInInfo, {
|
||||
success: () => {
|
||||
this.loading = false
|
||||
this.saveLabel = t('spreed', 'Saved!')
|
||||
setTimeout(() => {
|
||||
this.saveLabel = t('spreed', 'Save changes')
|
||||
}, 5000)
|
||||
},
|
||||
})
|
||||
},
|
||||
})
|
||||
await setSIPSettings(groups, this.sharedSecret, this.dialInInfo)
|
||||
|
||||
this.loading = false
|
||||
this.saveLabel = t('spreed', 'Saved!')
|
||||
setTimeout(() => {
|
||||
this.saveLabel = t('spreed', 'Save changes')
|
||||
}, 5000)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -152,6 +161,7 @@ export default {
|
|||
<style lang="scss" scoped>
|
||||
.sip-bridge {
|
||||
&__sip-groups-select,
|
||||
&__shared-secret,
|
||||
&__dialin-info {
|
||||
width: 480px;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,23 @@ const setAttachmentFolder = async function(path) {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the SIP settings
|
||||
*
|
||||
* @param {Array<string>} sipGroups The groups allowed to enable SIP on a conversation
|
||||
* @param {string} sharedSecret The shared secret which is used by the SIP server to authenticate
|
||||
* @param {string} dialInInfo The dial-in Information displayed in the email and sidebar
|
||||
* @returns {Object} The axios response
|
||||
*/
|
||||
const setSIPSettings = async function(sipGroups, sharedSecret, dialInInfo) {
|
||||
return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'sip', {
|
||||
sipGroups,
|
||||
sharedSecret,
|
||||
dialInInfo,
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
setAttachmentFolder,
|
||||
setSIPSettings,
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче