Skip to content

Commit

Permalink
fix(setting): add admin toggle for e2ee calls
Browse files Browse the repository at this point in the history
- Show setting only with HPB and adjust condition for being able to enable it

Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
  • Loading branch information
Antreesy committed Jan 15, 2025
1 parent 292aa49 commit 157ba59
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/components/AdminSettings/GeneralSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,38 @@

<NcCheckboxRadioSwitch :model-value="isConversationsFilesChecked"
:disabled="loading || loadingConversationsFiles"
type="switch"
@update:model-value="saveConversationsFiles">
{{ t('spreed', 'Allow conversations on files') }}
</NcCheckboxRadioSwitch>

<NcCheckboxRadioSwitch :model-value="isConversationsFilesPublicSharesChecked"
:disabled="loading || loadingConversationsFiles || !isConversationsFilesChecked"
type="switch"
@update:model-value="saveConversationsFilesPublicShares">
{{ t('spreed', 'Allow conversations on public shares for files') }}
</NcCheckboxRadioSwitch>

<template v-if="hasSignalingServers">
<h3>
{{ t('spreed', 'End-to-end encrypted calls') }}
<small>{{ t('spreed', 'Beta') }}</small>
</h3>

<NcCheckboxRadioSwitch v-model="isE2EECallsEnabled"
type="switch"
:disabled="loading || !canEnableE2EECalls"
@update:model-value="updateE2EECallsEnabled">
{{ t('spreed', 'Enable encryption') }}
</NcCheckboxRadioSwitch>

<NcNoteCard v-if="!canEnableE2EECalls"
type="warning"
:text="t('spreed', 'End-to-end encrypted calls with a configured SIP bridge require a newer version of the High-performance backend and SIP bridge.')" />
<NcNoteCard v-else
type="warning"
:text="t('spreed', 'Mobile clients do not support end-to-end encrypted calls at the moment.')" />
</template>
</section>
</template>

Expand All @@ -44,8 +67,11 @@ import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'

import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'

import { EventBus } from '../../services/EventBus.ts'

const defaultGroupNotificationOptions = [
{ value: 1, label: t('spreed', 'All messages') },
{ value: 2, label: t('spreed', '@-mentions only') },
Expand All @@ -55,6 +81,7 @@ export default {
name: 'GeneralSettings',

components: {
NcNoteCard,
NcCheckboxRadioSwitch,
NcSelect,
},
Expand All @@ -70,6 +97,11 @@ export default {

conversationsFiles: parseInt(loadState('spreed', 'conversations_files')) === 1,
conversationsFilesPublicShares: parseInt(loadState('spreed', 'conversations_files_public_shares')) === 1,

hasFeatureJoinFeatures: false,
hasSignalingServers: false,
isE2EECallsEnabled: false,
hasSIPBridge: !!loadState('spreed', 'sip_bridge_shared_secret'),
}
},

Expand All @@ -80,16 +112,53 @@ export default {
isConversationsFilesPublicSharesChecked() {
return this.conversationsFilesPublicShares
},
canEnableE2EECalls() {
return this.hasFeatureJoinFeatures || !this.hasSIPBridge
},
},

mounted() {
this.loading = true
this.defaultGroupNotification = defaultGroupNotificationOptions[parseInt(loadState('spreed', 'default_group_notification')) - 1]
this.loading = false

const signaling = loadState('spreed', 'signaling_servers')
this.updateSignalingServers(signaling.servers)
EventBus.on('signaling-servers-updated', this.updateSignalingServers)
EventBus.on('signaling-server-connected', this.updateSignalingDetails)
EventBus.on('sip-settings-updated', this.updateSipDetails)
},

beforeDestroy() {
EventBus.off('signaling-servers-updated', this.updateSignalingServers)
EventBus.off('signaling-server-connected', this.updateSignalingDetails)
EventBus.off('sip-settings-updated', this.updateSipDetails)
},

methods: {
t,

updateSignalingServers(servers) {
this.hasSignalingServers = servers.length > 0
},

updateSignalingDetails(signaling) {
this.hasFeatureJoinFeatures = signaling.hasFeature('join-features')
},

updateSipDetails(settings) {
this.hasSIPBridge = !!settings.sharedSecret
},

updateE2EECallsEnabled(value) {
this.loading = true
OCP.AppConfig.setValue('spreed', 'call_end_to_end_encryption', value ? '1' : '0', {
success: () => {
this.loading = false
},
})
},

saveDefaultGroupNotification() {
this.loadingDefaultGroupNotification = true

Expand Down Expand Up @@ -139,6 +208,13 @@ h3 {
font-weight: 600;
}

small {
color: var(--color-warning);
border: 1px solid var(--color-warning);
border-radius: 16px;
padding: 0 9px;
}

.default-group-notification {
min-width: 300px !important;
}
Expand Down
1 change: 1 addition & 0 deletions src/components/AdminSettings/SIPBridge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ export default {
dialOutEnabled: this.dialOutEnabled,
sipGroups: this.sipGroups.map(group => group.id).join('_')
}
EventBus.emit('sip-settings-updated', this.currentSetup)
},

async saveSIPSettings() {
Expand Down
2 changes: 2 additions & 0 deletions src/components/AdminSettings/SignalingServer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadi
import NcLoadingIcon from '@nextcloud/vue/dist/Components/NcLoadingIcon.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'

import { EventBus } from '../../services/EventBus.ts'
import { fetchSignalingSettings, getWelcomeMessage } from '../../services/signalingService.js'
import { createConnection } from '../../utils/SignalingStandaloneTest.js'

Expand Down Expand Up @@ -237,6 +238,7 @@ export default {
{ caption: t('spreed', 'WebSocket URL'), description: signalingTest.url },
{ caption: t('spreed', 'Available features'), description: signalingTest.features.join(', ') },
]
EventBus.emit('signaling-server-connected', signalingTest)
} catch (exception) {
console.error(exception)
this.errorMessage = t('spreed', 'Error: Websocket connection failed. Check browser console')
Expand Down

0 comments on commit 157ba59

Please sign in to comment.