diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-06-14 12:46:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-14 12:46:18 +0200 |
commit | 617aa3a484b175a19ea0c4987e051f9aaeeab4e3 (patch) | |
tree | 981e5a8aa9b339fe801762d70b5cb77526039016 /src | |
parent | f2f5ad85344c15f8e2bd4e1950e6f0f1532eebf1 (diff) | |
parent | e3bdf7251b44fc0c996a848e6fdaac370d024bcd (diff) |
Merge pull request #12208 from nextcloud/feat/11850/capabilities-wrapper
fix(capabilities): implement a wrapper for capabilities
Diffstat (limited to 'src')
43 files changed, 425 insertions, 181 deletions
diff --git a/src/__mocks__/capabilities.ts b/src/__mocks__/capabilities.ts new file mode 100644 index 000000000..d7048b030 --- /dev/null +++ b/src/__mocks__/capabilities.ts @@ -0,0 +1,159 @@ +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +import type { Capabilities } from '../types' + +export const mockedCapabilities: Capabilities = { + spreed: { + features: [ + 'audio', + 'video', + 'chat-v2', + 'conversation-v4', + 'guest-signaling', + 'empty-group-room', + 'guest-display-names', + 'multi-room-users', + 'favorites', + 'last-room-activity', + 'no-ping', + 'system-messages', + 'delete-messages', + 'mention-flag', + 'in-call-flags', + 'conversation-call-flags', + 'notification-levels', + 'invite-groups-and-mails', + 'locked-one-to-one-rooms', + 'read-only-rooms', + 'listable-rooms', + 'chat-read-marker', + 'chat-unread', + 'webinary-lobby', + 'start-call-flag', + 'chat-replies', + 'circles-support', + 'force-mute', + 'sip-support', + 'sip-support-nopin', + 'chat-read-status', + 'phonebook-search', + 'raise-hand', + 'room-description', + 'rich-object-sharing', + 'temp-user-avatar-api', + 'geo-location-sharing', + 'voice-message-sharing', + 'signaling-v3', + 'publishing-permissions', + 'clear-history', + 'direct-mention-flag', + 'notification-calls', + 'conversation-permissions', + 'rich-object-list-media', + 'rich-object-delete', + 'unified-search', + 'chat-permission', + 'silent-send', + 'silent-call', + 'send-call-notification', + 'talk-polls', + 'breakout-rooms-v1', + 'recording-v1', + 'avatar', + 'chat-get-context', + 'single-conversation-status', + 'chat-keep-notifications', + 'typing-privacy', + 'remind-me-later', + 'bots-v1', + 'markdown-messages', + 'media-caption', + 'session-state', + 'note-to-self', + 'recording-consent', + 'sip-support-dialout', + 'delete-messages-unlimited', + 'edit-messages', + 'silent-send-state', + 'chat-read-last', + 'federation-v1', + 'ban-v1', + ], + 'features-local': [ + 'favorites', + 'chat-read-status', + 'listable-rooms', + 'phonebook-search', + 'temp-user-avatar-api', + 'unified-search', + 'avatar', + 'remind-me-later', + 'note-to-self', + ], + config: { + attachments: { + allowed: true, + folder: '/Talk', + }, + call: { + enabled: true, + 'breakout-rooms': true, + recording: true, + 'recording-consent': 0, + 'supported-reactions': ['❤️', '🎉', '👏', '👍', '👎', '😂', '🤩', '🤔', '😲', '😥'], + 'predefined-backgrounds': ['1_office', '2_home', '3_abstract'], + 'can-upload-background': true, + 'sip-enabled': true, + 'sip-dialout-enabled': true, + 'can-enable-sip': true, + }, + chat: { + 'max-length': 32000, + 'read-privacy': 0, + 'has-translation-providers': true, + 'typing-privacy': 0, + }, + conversations: { + 'can-create': true, + }, + federation: { + enabled: false, + 'incoming-enabled': false, + 'outgoing-enabled': false, + 'only-trusted-servers': true, + }, + previews: { + 'max-gif-size': 3145728, + }, + signaling: { + 'session-ping-limit': 200, + }, + }, + 'config-local': { + attachments: [ + 'allowed', + 'folder', + ], + call: [ + 'predefined-backgrounds', + 'can-upload-background', + ], + chat: [ + 'read-privacy', + 'has-translation-providers', + 'typing-privacy', + ], + conversations: [ + 'can-create', + ], + federation: [], + previews: [ + 'max-gif-size', + ], + signaling: [], + }, + version: '20.0.0-dev.0', + } +} diff --git a/src/components/AdminSettings/RecordingServers.vue b/src/components/AdminSettings/RecordingServers.vue index dae1f7be8..db8602a17 100644 --- a/src/components/AdminSettings/RecordingServers.vue +++ b/src/components/AdminSettings/RecordingServers.vue @@ -76,7 +76,6 @@ import debounce from 'debounce' import Plus from 'vue-material-design-icons/Plus.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showSuccess } from '@nextcloud/dialogs' import { formatFileSize } from '@nextcloud/files' import { loadState } from '@nextcloud/initial-state' @@ -90,8 +89,9 @@ import RecordingServer from '../../components/AdminSettings/RecordingServer.vue' import TransitionWrapper from '../UIShared/TransitionWrapper.vue' import { CALL } from '../../constants.js' +import { hasTalkFeature } from '../../services/CapabilitiesManager.ts' -const recordingConsentCapability = getCapabilities()?.spreed?.features?.includes('recording-consent') +const recordingConsentCapability = hasTalkFeature('local', 'recording-consent') const recordingConsentOptions = [ { value: CALL.RECORDING_CONSENT.OFF, label: t('spreed', 'Disabled for all calls') }, { value: CALL.RECORDING_CONSENT.REQUIRED, label: t('spreed', 'Enabled for all calls') }, diff --git a/src/components/CallView/CallView.vue b/src/components/CallView/CallView.vue index 526c096cd..e62328e18 100644 --- a/src/components/CallView/CallView.vue +++ b/src/components/CallView/CallView.vue @@ -120,7 +120,6 @@ <script> import debounce from 'debounce' -import { getCapabilities } from '@nextcloud/capabilities' import { showMessage } from '@nextcloud/dialogs' import { subscribe, unsubscribe } from '@nextcloud/event-bus' @@ -136,12 +135,11 @@ import ViewerOverlayCallView from './shared/ViewerOverlayCallView.vue' import { SIMULCAST } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' import { fetchPeers } from '../../services/callsService.js' +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { EventBus } from '../../services/EventBus.js' import { localMediaModel, localCallParticipantModel, callParticipantCollection } from '../../utils/webrtc/index.js' import RemoteVideoBlocker from '../../utils/webrtc/RemoteVideoBlocker.js' -const supportedReactions = getCapabilities()?.spreed?.config?.call?.['supported-reactions'] - export default { name: 'CallView', @@ -175,7 +173,6 @@ export default { setup() { return { - supportedReactions, localMediaModel, localCallParticipantModel, callParticipantCollection, @@ -333,6 +330,10 @@ export default { showEmptyCallView() { return !this.callParticipantModels.length && !this.screenSharingActive }, + + supportedReactions() { + return getTalkConfig(this.token, 'call', 'supported-reactions') + }, }, watch: { diff --git a/src/components/ChatView.vue b/src/components/ChatView.vue index 3f62d3e40..56b713741 100644 --- a/src/components/ChatView.vue +++ b/src/components/ChatView.vue @@ -61,8 +61,6 @@ <script> import ChevronDoubleDown from 'vue-material-design-icons/ChevronDoubleDown.vue' -import { getCapabilities } from '@nextcloud/capabilities' - import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import GuestWelcomeWindow from './GuestWelcomeWindow.vue' @@ -72,12 +70,10 @@ import NewMessageUploadEditor from './NewMessage/NewMessageUploadEditor.vue' import TransitionWrapper from './UIShared/TransitionWrapper.vue' import { CONVERSATION, PARTICIPANT } from '../constants.js' +import { getTalkConfig, hasTalkFeature } from '../services/CapabilitiesManager.ts' import { EventBus } from '../services/EventBus.js' import { useChatExtrasStore } from '../stores/chatExtras.js' -const attachmentsAllowed = getCapabilities()?.spreed?.config?.attachments?.allowed -const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1') - export default { name: 'ChatView', @@ -124,10 |