mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
fix: move expensive capabilities check from URL generation service
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
This commit is contained in:
parent
cdaf2f9ae1
commit
b9d9fd5109
2 changed files with 20 additions and 6 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue