Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/services/conversationsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }))
}

/**
Expand Down Expand Up @@ -433,6 +441,7 @@ export {
fetchNoteToSelfConversation,
makeConversationPrivate,
makeConversationPublic,
makeLegacyConversationPublic,
markAsImportant,
markAsInsensitive,
markAsSensitive,
Expand Down
7 changes: 6 additions & 1 deletion src/store/conversationsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
fetchConversations,
makeConversationPrivate,
makeConversationPublic,
makeLegacyConversationPublic,
markAsImportant,
markAsInsensitive,
markAsSensitive,
Expand Down Expand Up @@ -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 {
Expand Down
Loading