diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-05-08 18:49:20 +0200 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2024-06-14 10:27:26 +0200 |
commit | 62eea8bcb4203a9a7ecab7f68612cbaace3b7482 (patch) | |
tree | ae74881dc635fccb12d7dae96c2b290cc0c7be4a /src | |
parent | d9f80e4dc5a4ba8647a3b2d2a7b19854153f8b2d (diff) |
feat(capabilities): apply manager for dynamic capabilities (conversation related)
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'src')
21 files changed, 97 insertions, 120 deletions
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 +120,10 @@ export default { }, canUploadFiles() { - return attachmentsAllowed && this.$store.getters.getUserId() + return getTalkConfig(this.token, 'attachments', 'allowed') && this.$store.getters.getUserId() && this.$store.getters.getAttachmentFolderFreeSpace() !== 0 && (this.conversation.permissions & PARTICIPANT.PERMISSIONS.CHAT) - && (!supportFederationV1 || !this.conversation.remoteServer) + && (!hasTalkFeature(this.token, 'federation-v1') || !this.conversation.remoteServer) }, isDragAndDropBlocked() { diff --git a/src/components/ConversationSettings/ConversationSettingsDialog.vue b/src/components/ConversationSettings/ConversationSettingsDialog.vue index f0e862f3a..6816a2f25 100644 --- a/src/components/ConversationSettings/ConversationSettingsDialog.vue +++ b/src/components/ConversationSettings/ConversationSettingsDialog.vue @@ -72,7 +72,7 @@ </NcAppSettingsSection> <!-- Bots settings --> - <NcAppSettingsSection v-if="selfIsOwnerOrModerator && hasBotV1API" + <NcAppSettingsSection v-if="selfIsOwnerOrModerator && supportBotsV1" id="bots" :name="t('spreed', 'Bots')"> <BotsSettings :token="token" /> @@ -92,7 +92,6 @@ </template> <script> -import { getCapabilities } from '@nextcloud/capabilities' import { subscribe, unsubscribe } from '@nextcloud/event-bus' import { loadState } from '@nextcloud/initial-state' @@ -116,13 +115,9 @@ import RecordingConsentSettings from './RecordingConsentSettings.vue' import SipSettings from './SipSettings.vue' import { CALL, PARTICIPANT, CONVERSATION } from '../../constants.js' +import { getTalkConfig, hasTalkFeature } from '../../services/CapabilitiesManager.ts' import { useSettingsStore } from '../../stores/settings.js' -const recordingEnabled = getCapabilities()?.spreed?.config?.call?.recording || false -const recordingConsentCapability = getCapabilities()?.spreed?.features?.includes('recording-consent') -const recordingConsent = getCapabilities()?.spreed?.config?.call?.['recording-consent'] !== CALL.RECORDING_CONSENT.OFF -const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1') - export default { name: 'ConversationSettingsDialog', @@ -181,7 +176,7 @@ export default { }, showMediaSettingsToggle() { - return (!supportFederationV1 || !this.conversation.remoteServer) + return (!hasTalkFeature(this.token, 'federation-v1') || !this.conversation.remoteServer) }, showMediaSettings() { @@ -218,19 +213,20 @@ export default { return this.conversation.objectType === CONVERSATION.OBJECT_TYPE.BREAKOUT_ROOM }, - hasBotV1API() { - return getCapabilities()?.spreed?.features?.includes('bots-v1') + supportBotsV1() { + return hasTalkFeature(this.token, 'bots-v1') }, canConfigureBreakoutRooms() { - const breakoutRoomsEnabled = getCapabilities()?.spreed?.config?.call?.['breakout-rooms'] || false return this.canFullModerate - && breakoutRoomsEnabled + && (getTalkConfig(this.token, 'call', 'breakout-rooms') || false) && this.conversation.type === CONVERSATION.TYPE.GROUP }, recordingConsentAvailable() { - return recordingEnabled && recordingConsentCapability && recordingConsent + return (getTalkConfig(this.token, 'call', 'recording') || false) + && hasTalkFeature(this.token, 'recording-consent') + && getTalkConfig(this.token, 'call', 'recording-consent') !== CALL.RECORDING_CONSENT.OFF }, recordingConsentRequired() { diff --git a/src/components/ConversationSettings/NotificationsSettings.vue b/src/components/ConversationSettings/NotificationsSettings.vue index 86b4131fe..149ea7276 100644 --- a/src/components/ConversationSettings/NotificationsSettings.vue +++ b/src/components/ConversationSettings/NotificationsSettings.vue @@ -37,13 +37,10 @@ import Account from 'vue-material-design-icons/Account.vue' import VolumeHigh from 'vue-material-design-icons/VolumeHigh.vue' import VolumeOff from 'vue-material-design-icons/VolumeOff.vue' -import { getCapabilities } from '@nextcloud/capabilities' - import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' import { PARTICIPANT } from '../../constants.js' - -const supportFederationV1 = getCapabilities()?.spreed?.features?.includes('federation-v1') +import { hasTalkFeature } from '../../services/CapabilitiesManager.ts' const notificationLevels = [ { value: PARTICIPANT.NOTIFY.ALWAYS, label: t('spreed', 'All messages') }, @@ -80,7 +77,7 @@ export default { computed: { showCallNotificationSettings() { - return (!supportFederationV1 || !this.conversation.remoteServer) + return (!hasTalkFeature(this.conversation.token, 'federation-v1') || !this.conversation.remoteServer) } }, diff --git a/src/components/ConversationSettings/RecordingConsentSettings.vue b/src/components/ConversationSettings/RecordingConsentSettings.vue index 43cddbc6f..7b8ff2102 100644 --- a/src/components/ConversationSettings/RecordingConsentSettings.vue +++ b/src/components/ConversationSettings/RecordingConsentSettings.vue @@ -28,14 +28,12 @@ </template> <script> -import { getCapabilities } from '@nextcloud/capabilities' import { showError, showSuccess } from '@nextcloud/dialogs' import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' import { CALL, CONVERSATION } from '../../constants.js' - -const recordingConsent = getCapabilities()?.spreed?.config?.call?.['recording-consent'] +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' export default { name: 'RecordingConsentSettings', @@ -69,7 +67,7 @@ export default { }, isGlobalConsent() { - return recordingConsent === CALL.RECORDING_CONSENT.REQUIRED + return getTalkConfig(this.token, 'call', 'recording-consent') === CALL.RECORDING_CONSENT.REQUIRED }, isBreakoutRoomStarted() { diff --git a/src/components/MediaSettings/MediaSettings.vue b/src/components/MediaSettings/MediaSettings.vue index ea8bb05bb..1009f4249 100644 --- a/src/components/MediaSettings/MediaSettings.vue +++ b/src/components/MediaSettings/MediaSettings.vue @@ -192,7 +192,6 @@ import Creation from 'vue-material-design-icons/Creation.vue' import VideoIcon from 'vue-material-design-icons/Video.vue' import VideoOff from 'vue-material-design-icons/VideoOff.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' @@ -215,13 +214,11 @@ import { useDevices } from '../../composables/useDevices.js' import { useIsInCall } from '../../composables/useIsInCall.js' import { AVATAR, CALL, PARTICIPANT, VIRTUAL_BACKGROUND } from '../../constants.js' import BrowserStorage from '../../services/BrowserStorage.js' +import { getTalkConfig } from '../../services/CapabilitiesManager.ts' import { useGuestNameStore } from '../../stores/guestName.js' import { useSettingsStore } from '../../stores/settings.js' import { localMediaModel } from '../../utils/webrtc/index.js' -const recordingEnabled = getCapabilities()?.spreed?.config?.call?.recording || false -const recordingConsent = getCapabilities()?.spreed?.config?.call?.['recording-consent'] - export default { name: 'MediaSettings', @@ -392,12 +389,16 @@ export default { }, canModerateRecording() { - return this.canFullModerate && recordingEnabled + return this.canFullModerate && (getTalkConfig(this.token, 'call', 'recording') || false) + }, + + recordingConsent() { + return getTalkConfig(this.token, 'call', 'recording-consent') }, isRecordingConsentRequired() { - return recordingConsent === CALL.RECORDING_CONSENT.REQUIRED - || (recordingConsent === CALL.RECORDING_CONSENT.OPTIONAL && this.conversation.recordingConsent === CALL.RECORDING_CONSENT.REQUIRED) + return this.recordingConsent === CALL.RECORDING_CONSENT.REQUIRED + || (this.recordingConsent === CALL.RECORDING_CONSENT.OPTIONAL && this.conversation.recordingConsent === CALL.RECORDING_CONSENT.REQUIRED) }, showRecordingWarning() { diff --git a/src/components/MessagesList/MessagesGroup/Message/Message.vue b/src/components/MessagesList/MessagesGroup/Message/Message.vue index b77f5e70f..f40cd1459 100644 --- a/src/components/MessagesList/MessagesGroup/Message/Message.vue +++ b/src/components/MessagesList/MessagesGroup/Message/Message.vue @@ -89,7 +89,6 @@ import UnfoldLess from 'vue-material-design-icons/UnfoldLessHorizontal.vue' import UnfoldMore from 'vue-material-design-icons/UnfoldMoreHorizontal.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showError, showSuccess, showWarning, TOAST_DEFAULT_TIMEOUT } from '@nextcloud/dialogs' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' @@ -108,14 +107,11 @@ import Poll from './MessagePart/Poll.vue' import Reactions from './MessagePart/Reactions.vue' import { CONVERSATION, PARTICIPANT } from '../../../../constants.js' +import { getTalkConfig } from '../../../../services/CapabilitiesManager.ts' import { EventBus } from '../../../../services/EventBus.js' import { useChatExtrasStore } from '../../../../stores/chatExtras.js' import { getItemTypeFromMessage } from '../../../../utils/getItemTypeFromMessage.ts' -const isTranslationAvailable = getCapabilities()?.spreed?.config?.chat?.['has-translation-providers'] - // Fallback for the desktop client when connecting to Talk 17 - ?? getCapabilities()?.spreed?.config?.chat?.translations?.length > 0 - export default { name: 'Message', @@ -173,7 +169,11 @@ export default { emits: ['toggle-combined-system-message'], - setup() { + setup(props) { + const isTranslationAvailable = getTalkConfig(props.token, 'chat', 'has-translation-providers') + // Fallback for the desktop client when connecting to Talk 17 + ?? getTalkConfig(props.token, 'chat', 'translations')?.length > 0 + return { isTranslationAvailable, chatExtrasStore: useChatExtrasStore(), diff --git a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue index 492518744..f79bdbe84 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessageButtonsBar/MessageButtonsBar.vue @@ -273,7 +273,6 @@ import Reply from 'vue-material-design-icons/Reply.vue' import Share from 'vue-material-design-icons/Share.vue' import Translate from 'vue-material-design-icons/Translate.vue' -import { getCapabilities } from '@nextcloud/capabilities' import { showError, showSuccess } from '@nextcloud/dialogs' import moment from '@nextcloud/moment' @@ -289,14 +288,13 @@ import { emojiSearch } from '@nextcloud/vue/dist/Functions/emoji.js' import { useMessageInfo } from '../../../../../composables/useMessageInfo.js' import { CONVERSATION, ATTENDEE } from '../../../../../constants.js' +import { hasTalkFeature } from '../../../../../services/CapabilitiesManager.ts' import { getMessageReminder, removeMessageReminder, setMessageReminder } from '../../../../../services/remindersService.js' import { useIntegrationsStore } from '../../../../../stores/integrations.js' import { useReactionsStore } from '../../../../../stores/reactions.js' import { copyConversationLinkToClipboard } from '../../../../../utils/handleUrl.ts' import { parseMentions } from '../../../../../utils/textParse.ts' -const supportReminders = getCapabilities()?.spreed?.features?.includes('remind-me-later') - export default { name: 'MessageButtonsBar', @@ -398,6 +396,7 @@ export default { isConversationReadOnly, isConversationModifiable, } = useMessageInfo(message) + const supportReminders = hasTalkFeature(message.value.token, 'remind-me-later') return { messageActions, diff --git a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue index ddd774e14..faa05a858 100644 --- a/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue +++ b/src/components/MessagesList/MessagesGroup/Message/MessagePart/FilePreview.vue @@ -61,7 +61,6 @@ import Close from 'vue-material-design-icons/Close.vue' |