Skip to content

Commit c2b4b86

Browse files
authored
Merge pull request #16427 from nextcloud/backport/16418/stable32
2 parents 4093479 + 6b4fd66 commit c2b4b86

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/services/conversationsService.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ import type {
5757

5858
import axios from '@nextcloud/axios'
5959
import { generateOcsUrl } from '@nextcloud/router'
60-
import { hasTalkFeature } from './CapabilitiesManager.ts'
6160

6261
/**
6362
* Fetches all conversations from the server.
@@ -289,10 +288,19 @@ async function setNotificationCalls(token: string, level: setConversationNotifyC
289288
* @param password The password to set for the conversation (optional, only if force password is enabled)
290289
*/
291290
async function makeConversationPublic(token: string, password: makeConversationPublicParams['password']): makeConversationPublicResponse {
292-
const data = (hasTalkFeature(token, 'conversation-creation-password') && password)
293-
? { password }
294-
: undefined
295-
return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token }), data as makeConversationPublicParams)
291+
return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token }), {
292+
password,
293+
} as makeConversationPublicParams)
294+
}
295+
296+
/**
297+
* Make the conversation public (legacy method, doesn't support password payload)
298+
* Capability check for 'conversation-creation-password'
299+
*
300+
* @param token The token of the conversation to be removed from favorites
301+
*/
302+
async function makeLegacyConversationPublic(token: string): makeConversationPublicResponse {
303+
return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token }))
296304
}
297305

298306
/**
@@ -433,6 +441,7 @@ export {
433441
fetchNoteToSelfConversation,
434442
makeConversationPrivate,
435443
makeConversationPublic,
444+
makeLegacyConversationPublic,
436445
markAsImportant,
437446
markAsInsensitive,
438447
markAsSensitive,

src/store/conversationsStore.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
fetchConversations,
3535
makeConversationPrivate,
3636
makeConversationPublic,
37+
makeLegacyConversationPublic,
3738
markAsImportant,
3839
markAsInsensitive,
3940
markAsSensitive,
@@ -553,7 +554,11 @@ const actions = {
553554
try {
554555
const conversation = { ...getters.conversation(token) }
555556
if (allowGuests) {
556-
await makeConversationPublic(token, password)
557+
if (hasTalkFeature(token, 'conversation-creation-password')) {
558+
await makeConversationPublic(token, password)
559+
} else {
560+
await makeLegacyConversationPublic(token)
561+
}
557562
conversation.type = CONVERSATION.TYPE.PUBLIC
558563
showSuccess(t('spreed', 'You allowed guests'))
559564
} else {

0 commit comments

Comments
 (0)