diff --git a/src/services/conversationsService.ts b/src/services/conversationsService.ts index 54c26385a14..16762f0bd4b 100644 --- a/src/services/conversationsService.ts +++ b/src/services/conversationsService.ts @@ -57,7 +57,6 @@ import type { import axios from '@nextcloud/axios' import { generateOcsUrl } from '@nextcloud/router' -import { hasTalkFeature } from './CapabilitiesManager.ts' /** * Fetches all conversations from the server. @@ -289,10 +288,19 @@ async function setNotificationCalls(token: string, level: setConversationNotifyC * @param password The password to set for the conversation (optional, only if force password is enabled) */ async function makeConversationPublic(token: string, password: makeConversationPublicParams['password']): makeConversationPublicResponse { - const data = (hasTalkFeature(token, 'conversation-creation-password') && password) - ? { password } - : undefined - return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token }), data as makeConversationPublicParams) + return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token }), { + password, + } as makeConversationPublicParams) +} + +/** + * Make the conversation public (legacy method, doesn't support password payload) + * Capability check for 'conversation-creation-password' + * + * @param token The token of the conversation to be removed from favorites + */ +async function makeLegacyConversationPublic(token: string): makeConversationPublicResponse { + return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token })) } /** @@ -433,6 +441,7 @@ export { fetchNoteToSelfConversation, makeConversationPrivate, makeConversationPublic, + makeLegacyConversationPublic, markAsImportant, markAsInsensitive, markAsSensitive, diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index c00021f3514..c78a92a3805 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -34,6 +34,7 @@ import { fetchConversations, makeConversationPrivate, makeConversationPublic, + makeLegacyConversationPublic, markAsImportant, markAsInsensitive, markAsSensitive, @@ -553,7 +554,11 @@ const actions = { try { const conversation = { ...getters.conversation(token) } if (allowGuests) { - await makeConversationPublic(token, password) + if (hasTalkFeature(token, 'conversation-creation-password')) { + await makeConversationPublic(token, password) + } else { + await makeLegacyConversationPublic(token) + } conversation.type = CONVERSATION.TYPE.PUBLIC showSuccess(t('spreed', 'You allowed guests')) } else {