diff options
author | Joas Schilling <coding@schilljs.com> | 2021-05-19 14:27:18 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-05-19 14:27:18 +0300 |
commit | 2c553092fb857f209503127b3d3573cc9deafa51 (patch) | |
tree | 6d9bcc6b9e8a8daceafcfc2e41708e04bf886ceb /src | |
parent | 1617bb1404db88b5e049b2962b5f9796b7cb5375 (diff) |
Fix generateOcsUrl() calls
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src')
22 files changed, 81 insertions, 81 deletions
diff --git a/src/components/AdminSettings/AllowedGroups.vue b/src/components/AdminSettings/AllowedGroups.vue index f99ba4379..b142075b2 100644 --- a/src/components/AdminSettings/AllowedGroups.vue +++ b/src/components/AdminSettings/AllowedGroups.vue @@ -165,7 +165,7 @@ export default { searchGroup: debounce(async function(query) { this.loadingGroups = true try { - const response = await axios.get(generateOcsUrl('cloud', 2) + 'groups/details', { + const response = await axios.get(generateOcsUrl('cloud/groups/details'), { search: query, limit: 20, offset: 0, diff --git a/src/components/AdminSettings/HostedSignalingServer.vue b/src/components/AdminSettings/HostedSignalingServer.vue index 44862c116..5394779dc 100644 --- a/src/components/AdminSettings/HostedSignalingServer.vue +++ b/src/components/AdminSettings/HostedSignalingServer.vue @@ -218,7 +218,7 @@ export default { this.requestError = '' this.loading = true try { - const res = await axios.post(generateOcsUrl('apps/spreed/api/v1/hostedsignalingserver', 2) + 'requesttrial', { + const res = await axios.post(generateOcsUrl('apps/spreed/api/v1/hostedsignalingserver/requesttrial'), { url: this.hostedHPBNextcloudUrl, name: this.hostedHPBFullName, email: this.hostedHPBEmail, @@ -239,7 +239,7 @@ export default { this.loading = true try { - await axios.delete(generateOcsUrl('apps/spreed/api/v1/hostedsignalingserver', 2) + 'delete') + await axios.delete(generateOcsUrl('apps/spreed/api/v1/hostedsignalingserver/delete')) this.trialAccount = [] } catch (err) { diff --git a/src/components/AdminSettings/SIPBridge.vue b/src/components/AdminSettings/SIPBridge.vue index d7b70a685..5530f92cb 100644 --- a/src/components/AdminSettings/SIPBridge.vue +++ b/src/components/AdminSettings/SIPBridge.vue @@ -133,7 +133,7 @@ export default { searchGroup: debounce(async function(query) { this.loadingGroups = true try { - const response = await axios.get(generateOcsUrl('cloud', 2) + 'groups/details', { + const response = await axios.get(generateOcsUrl('cloud/groups/details'), { search: query, limit: 20, offset: 0, diff --git a/src/services/callsService.js b/src/services/callsService.js index bcded40d3..ffb81d2cc 100644 --- a/src/services/callsService.js +++ b/src/services/callsService.js @@ -54,7 +54,7 @@ const leaveCall = async function(token) { } const fetchPeers = async function(token, options) { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v4', 2) + `call/${token}`, options) + const response = await axios.get(generateOcsUrl('apps/spreed/api/v4/call/{token}', { token }), options) return response } diff --git a/src/services/conversationsService.js b/src/services/conversationsService.js index e8588fa1a..49d28bbbc 100644 --- a/src/services/conversationsService.js +++ b/src/services/conversationsService.js @@ -28,7 +28,7 @@ import { CONVERSATION, SHARE } from '../constants' * Fetches the conversations from the server. */ const fetchConversations = async function() { - return axios.get(generateOcsUrl('apps/spreed/api/v4', 2) + 'room') + return axios.get(generateOcsUrl('apps/spreed/api/v4/room')) } /** @@ -36,7 +36,7 @@ const fetchConversations = async function() { * @param {string} token The token of the conversation to be fetched. */ const fetchConversation = async function(token) { - return axios.get(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}`) + return axios.get(generateOcsUrl('apps/spreed/api/v4/room/{token}', { token })) } /** @@ -45,7 +45,7 @@ const fetchConversation = async function(token) { * @param {object} options options */ const searchListedConversations = async function({ searchText }, options) { - return axios.get(generateOcsUrl('apps/spreed/api/v4', 2) + 'listed-room', Object.assign(options, { + return axios.get(generateOcsUrl('apps/spreed/api/v4/room/listed-room'), Object.assign(options, { params: { searchTerm: searchText, }, @@ -75,7 +75,7 @@ const searchPossibleConversations = async function({ searchText, token, onlyUser } } - return axios.get(generateOcsUrl('core/autocomplete', 2) + `get`, Object.assign(options, { + return axios.get(generateOcsUrl('core/autocomplete/get'), Object.assign(options, { params: { search: searchText, itemType: 'call', @@ -91,7 +91,7 @@ const searchPossibleConversations = async function({ searchText, token, onlyUser */ const createOneToOneConversation = async function(userId) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room`, { roomType: CONVERSATION.TYPE.ONE_TO_ONE, invite: userId }) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room'), { roomType: CONVERSATION.TYPE.ONE_TO_ONE, invite: userId }) return response } catch (error) { console.debug('Error creating new one to one conversation: ', error) @@ -105,7 +105,7 @@ const createOneToOneConversation = async function(userId) { */ const createGroupConversation = async function(invite, source) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room`, { roomType: CONVERSATION.TYPE.GROUP, invite, source: source || 'groups' }) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room'), { roomType: CONVERSATION.TYPE.GROUP, invite, source: source || 'groups' }) return response } catch (error) { console.debug('Error creating new group conversation: ', error) @@ -118,7 +118,7 @@ const createGroupConversation = async function(invite, source) { */ const createPrivateConversation = async function(conversationName) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room`, { roomType: CONVERSATION.TYPE.GROUP, roomName: conversationName }) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room'), { roomType: CONVERSATION.TYPE.GROUP, roomName: conversationName }) return response } catch (error) { console.debug('Error creating new private conversation: ', error) @@ -131,7 +131,7 @@ const createPrivateConversation = async function(conversationName) { */ const createPublicConversation = async function(conversationName) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room`, { roomType: CONVERSATION.TYPE.PUBLIC, roomName: conversationName }) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room'), { roomType: CONVERSATION.TYPE.PUBLIC, roomName: conversationName }) return response } catch (error) { console.debug('Error creating new public conversation: ', error) @@ -144,7 +144,7 @@ const createPublicConversation = async function(conversationName) { * @param {string} password the password to be set */ const setConversationPassword = async function(token, password) { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/password`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}/password', { token }), { password, }) return response @@ -156,7 +156,7 @@ const setConversationPassword = async function(token, password) { * @param {string} name the name to be set */ const setConversationName = async function(token, name) { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}', { token }), { roomName: name, }) return response @@ -168,7 +168,7 @@ const setConversationName = async function(token, name) { */ const deleteConversation = async function(token) { try { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}`) + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}', { token })) return response } catch (error) { console.debug('Error while deleting the conversation: ', error) @@ -181,7 +181,7 @@ const deleteConversation = async function(token) { */ const addToFavorites = async function(token) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/favorite`) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/favorite', { token })) return response } catch (error) { console.debug('Error while adding the conversation to favorites: ', error) @@ -194,7 +194,7 @@ const addToFavorites = async function(token) { */ const removeFromFavorites = async function(token) { try { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/favorite`) + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/favorite', { token })) return response } catch (error) { console.debug('Error while removing the conversation from favorites: ', error) @@ -208,7 +208,7 @@ const removeFromFavorites = async function(token) { */ const setNotificationLevel = async function(token, level) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/notify`, { level }) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/notify', { token }), { level }) return response } catch (error) { console.debug('Error while setting the notification level: ', error) @@ -221,7 +221,7 @@ const setNotificationLevel = async function(token, level) { */ const makePublic = async function(token) { try { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/public`) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token })) return response } catch (error) { console.debug('Error while making the conversation public: ', error) @@ -234,7 +234,7 @@ const makePublic = async function(token) { */ const makePrivate = async function(token) { try { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/public`) + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/public', { token })) return response } catch (error) { console.debug('Error while making the conversation private: ', error) @@ -247,7 +247,7 @@ const makePrivate = async function(token) { * @param {int} newState The new SIP state to set */ const setSIPEnabled = async function(token, newState) { - return axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/webinar/sip`, { + return axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}/webinar/sip', { token }), { state: newState, }) } @@ -260,7 +260,7 @@ const setSIPEnabled = async function(token, newState) { */ const changeLobbyState = async function(token, newState, timestamp) { try { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/webinar/lobby`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}/webinar/lobby', { token }), { state: newState, timer: timestamp, }) @@ -277,7 +277,7 @@ const changeLobbyState = async function(token, newState, timestamp) { */ const changeReadOnlyState = async function(token, readOnly) { try { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/read-only`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}/read-only', { token }), { state: readOnly, }) return response @@ -292,14 +292,14 @@ const changeReadOnlyState = async function(token, readOnly) { * @param {int} listable The new listable scope to set */ const changeListable = async function(token, listable) { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/listable`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}/listable', { token }), { scope: listable, }) return response } const setConversationDescription = async function(token, description) { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/description`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v4/room/{token}/description', { token }), { description, }) return response diff --git a/src/services/conversationsService.spec.js b/src/services/conversationsService.spec.js index 0dcd32c36..14413b31b 100644 --- a/src/services/conversationsService.spec.js +++ b/src/services/conversationsService.spec.js @@ -21,7 +21,7 @@ describe('conversationsService', () => { } ) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('core/autocomplete', 2) + 'get', + generateOcsUrl('core/autocomplete/get'), { dummyOption: true, params: { diff --git a/src/services/filesIntegrationServices.js b/src/services/filesIntegrationServices.js index 36826897d..578e2f69b 100644 --- a/src/services/filesIntegrationServices.js +++ b/src/services/filesIntegrationServices.js @@ -31,7 +31,7 @@ import { generateOcsUrl } from '@nextcloud/router' * @returns {String} the conversation token */ const getFileConversation = async function({ fileId }, options) { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + `file/${fileId}`) + const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/file/{fileId}', { fileId })) return response } @@ -43,7 +43,7 @@ const getFileConversation = async function({ fileId }, options) { * @throws {Exception} if the conversation token could not be got */ const getPublicShareConversationData = async function(shareToken) { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + `publicshare/${shareToken}`) + const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/publicshare/{shareToken}', { shareToken })) return response.data.ocs.data } diff --git a/src/services/filesSharingServices.js b/src/services/filesSharingServices.js index f959cc89d..35ad3470b 100644 --- a/src/services/filesSharingServices.js +++ b/src/services/filesSharingServices.js @@ -33,7 +33,7 @@ import { showError } from '@nextcloud/dialogs' const shareFile = async function(path, token, referenceId) { try { return axios.post( - generateOcsUrl('apps/files_sharing/api/v1', 2) + 'shares', + generateOcsUrl('apps/files_sharing/api/v1/shares'), { shareType: 10, // OC.Share.SHARE_TYPE_ROOM, path, diff --git a/src/services/filesSharingServices.spec.js b/src/services/filesSharingServices.spec.js index 44ec99725..2ac80d293 100644 --- a/src/services/filesSharingServices.spec.js +++ b/src/services/filesSharingServices.spec.js @@ -12,7 +12,7 @@ describe('filesSharingServices', () => { shareFile('path/to/file', 'XXTOKENXX', 'the-reference-id') expect(mockAxios.post).toHaveBeenCalledWith( - generateOcsUrl('apps/files_sharing/api/v1', 2) + 'shares', + generateOcsUrl('apps/files_sharing/api/v1/shares'), { shareType: 10, shareWith: 'XXTOKENXX', diff --git a/src/services/matterbridgeService.js b/src/services/matterbridgeService.js index 9b4dd125d..c84f444e9 100644 --- a/src/services/matterbridgeService.js +++ b/src/services/matterbridgeService.js @@ -33,7 +33,7 @@ import { * @param {string} parts parts of the bridge, where it has to connect */ const editBridge = async function(token, enabled, parts) { - const response = await axios.put(generateOcsUrl('apps/spreed/api/v1', 2) + `bridge/${token}`, { + const response = await axios.put(generateOcsUrl('apps/spreed/api/v1/bridge/{token}', { token }), { token, enabled, parts, @@ -46,7 +46,7 @@ const editBridge = async function(token, enabled, parts) { * @param {token} token the conversation token. */ const getBridge = async function(token) { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + `bridge/${token}`) + const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/bridge/{token}', { token })) return response } @@ -55,7 +55,7 @@ const getBridge = async function(token) { * @param {token} token the conversation token. */ const getBridgeProcessState = async function(token) { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + `bridge/${token}/process`) + const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/bridge/{token}/process', { token })) return response } @@ -63,7 +63,7 @@ const getBridgeProcessState = async function(token) { * Ask to stop all bridges (and kill all related processes) */ const stopAllBridges = async function() { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v1', 2) + 'bridge') + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v1/bridge')) return response } @@ -73,7 +73,7 @@ const enableMatterbridgeApp = async function() { } const getMatterbridgeVersion = async function() { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v1', 2) + 'bridge/version') + const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/bridge/version')) return response } diff --git a/src/services/mentionsService.js b/src/services/mentionsService.js index d8917a562..01bf38df1 100644 --- a/src/services/mentionsService.js +++ b/src/services/mentionsService.js @@ -30,7 +30,7 @@ import { generateOcsUrl } from '@nextcloud/router' */ const searchPossibleMentions = async function(token, searchText) { try { - const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/chat', 2) + `${token}/mentions`, { + const response = await axios.get(generateOcsUrl('apps/spreed/api/v1/chat/{token}/mentions', { token }), { params: { search: searchText, includeStatus: 1, diff --git a/src/services/messagesService.js b/src/services/messagesService.js index 0869dde12..630445f23 100644 --- a/src/services/messagesService.js +++ b/src/services/messagesService.js @@ -35,7 +35,7 @@ import Hex from 'crypto-js/enc-hex' * @param {bool} includeLastKnown whether to include the last known message in the response; */ const fetchMessages = async function({ token, lastKnownMessageId, includeLastKnown }, options) { - return axios.get(generateOcsUrl('apps/spreed/api/v1/chat', 2) + token, Object.assign(options, { + return axios.get(generateOcsUrl('apps/spreed/api/v1/chat/{token}', { token }), Object.assign(options, { params: { setReadMarker: 0, lookIntoFuture: 0, @@ -54,7 +54,7 @@ const fetchMessages = async function({ token, lastKnownMessageId, includeLastKno * @param {int} lastKnownMessageId The id of the last message in the store. */ const lookForNewMessages = async({ token, lastKnownMessageId }, options) => { - return axios.get(generateOcsUrl('apps/spreed/api/v1/chat', 2) + token, Object.assign(options, { + return axios.get(generateOcsUrl('apps/spreed/api/v1/chat/{token}', { token }), Object.assign(options, { params: { setReadMarker: 0, lookIntoFuture: 1, @@ -75,7 +75,7 @@ const lookForNewMessages = async({ token, lastKnownMessageId }, options) => { * @param {object} options request options */ const postNewMessage = async function({ token, message, actorDisplayName, referenceId, parent }, options) { - return axios.post(generateOcsUrl('apps/spreed/api/v1/chat', 2) + token, { + return axios.post(generateOcsUrl('apps/spreed/api/v1/chat/{token}', { token }), { message, actorDisplayName, referenceId, @@ -91,7 +91,7 @@ const postNewMessage = async function({ token, message, actorDisplayName, refere * @param {string} id The id of the message to be deleted */ const deleteMessage = async function({ token, id }) { - return axios.delete(generateOcsUrl('apps/spreed/api/v1/chat', 2) + token + '/' + id) + return axios.delete(generateOcsUrl('apps/spreed/api/v1/chat/{token}/{id}', { token, id })) } /** @@ -108,7 +108,7 @@ const postRichObjectToConversation = async function(token, { objectType, objectI const tempId = 'richobject-' + objectType + '-' + objectId + '-' + token + '-' + (new Date().getTime()) referenceId = Hex.stringify(SHA1(tempId)) } - return axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `chat/${token}/share`, { + return axios.post(generateOcsUrl('apps/spreed/api/v1/chat/{token}/share', { token }), { objectType, objectId, metaData, @@ -123,7 +123,7 @@ const postRichObjectToConversation = async function(token, { objectType, objectI * @param {int} lastReadMessage id of the last read message to set */ const updateLastReadMessage = async function(token, lastReadMessage) { - return axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `chat/${token}/read`, { + return axios.post(generateOcsUrl('apps/spreed/api/v1/chat/{token}/read', { token }), { lastReadMessage, }) } diff --git a/src/services/messagesService.spec.js b/src/services/messagesService.spec.js index 971339a99..b1078d000 100644 --- a/src/services/messagesService.spec.js +++ b/src/services/messagesService.spec.js @@ -25,7 +25,7 @@ describe('messagesService', () => { }) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX', + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX'), { dummyOption: true, params: { @@ -48,7 +48,7 @@ describe('messagesService', () => { }) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX', + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX'), { dummyOption: true, params: { @@ -70,7 +70,7 @@ describe('messagesService', () => { }) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX', + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX'), { dummyOption: true, params: { @@ -95,7 +95,7 @@ describe('messagesService', () => { }) expect(mockAxios.post).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX', + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX'), { message: 'hello world!', actorDisplayName: 'actor-display-name', @@ -115,7 +115,7 @@ describe('messagesService', () => { }) expect(mockAxios.delete).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX/1234' + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX/1234'), ) }) @@ -128,7 +128,7 @@ describe('messagesService', () => { }) expect(mockAxios.post).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX/share', + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX/share'), { objectType: 'deck', objectId: 999, @@ -147,7 +147,7 @@ describe('messagesService', () => { const lastReq = mockAxios.lastReqGet() expect(lastReq.url) - .toBe(generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX/share') + .toBe(generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX/share')) expect(lastReq.data.objectType).toBe('deck') expect(lastReq.data.objectId).toBe(999) expect(lastReq.data.metaData).toBe('{"x":1}') @@ -158,7 +158,7 @@ describe('messagesService', () => { updateLastReadMessage('XXTOKENXX', 1234) expect(mockAxios.post).toHaveBeenCalledWith( - generateOcsUrl('apps/spreed/api/v1/chat', 2) + 'XXTOKENXX/read', + generateOcsUrl('apps/spreed/api/v1/chat/XXTOKENXX/read'), { lastReadMessage: 1234, } diff --git a/src/services/participantsService.js b/src/services/participantsService.js index 2d53c8135..111bad917 100644 --- a/src/services/participantsService.js +++ b/src/services/participantsService.js @@ -38,7 +38,7 @@ import { * @param {bool} forceJoin whether to force join; */ const joinConversation = async({ token, forceJoin = false }, options) => { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants/active`, { + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/active', { token }), { force: forceJoin, }, options) @@ -55,7 +55,7 @@ const joinConversation = async({ token, forceJoin = false }, options) => { * @param {string} token The conversation token; */ const rejoinConversation = async(token) => { - return axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants/active`) + return axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/active', { token })) } /** @@ -68,7 +68,7 @@ const leaveConversation = async function(token) { // FIXME Signaling should not be synchronous await signalingLeaveConversation(token) - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants/active`) + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/active', { token })) return response } catch (error) { console.debug(error) @@ -82,7 +82,7 @@ const leaveConversation = async function(token) { * @param {string} token The conversation token; */ const leaveConversationSync = function(token) { - axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants/active`) + axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/active', { token })) } /** @@ -92,7 +92,7 @@ const leaveConversationSync = function(token) { * @param {string} source the source Source of the participant as returned by the autocomplete suggestion endpoint (default is users) */ const addParticipant = async function(token, newParticipant, source) { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants`, { + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants', { token }), { newParticipant, source, }) @@ -105,12 +105,12 @@ const addParticipant = async function(token, newParticipant, source) { * @param {string} token The conversation token; */ const removeCurrentUserFromConversation = async function(token) { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants/self`) + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/self', { token })) return response } const removeAttendeeFromConversation = async function(token, attendeeId) { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/attendees`, { + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/attendees', { token }), { params: { attendeeId, }, @@ -119,12 +119,12 @@ const removeAttendeeFromConversation = async function(token, attendeeId) { } const promoteToModerator = async(token, options) => { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/moderators`, options) + const response = await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/moderators', { token }), options) return response } const demoteFromModerator = async(token, options) => { - const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/moderators`, { + const response = await axios.delete(generateOcsUrl('apps/spreed/api/v4/room/{token}/moderators', { token }), { params: options, }) return response @@ -134,12 +134,12 @@ const fetchParticipants = async(token, options) => { options = options || {} options.params = options.params || {} options.params.includeStatus = true - const response = await axios.get(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants`, options) + const response = await axios.get(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants', { token }), options) return response } const setGuestUserName = async(token, userName) => { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `/guest/${token}/name`, { + const response = await axios.post(generateOcsUrl('apps/spreed/api/v1/guest/{token}/name', { token }), { displayName: userName, }) return response @@ -153,7 +153,7 @@ const setGuestUserName = async(token, userName) => { * @param {int} attendeeId attendee id to target, or null for all */ const resendInvitations = async(token, { attendeeId = null }) => { - await axios.post(generateOcsUrl('apps/spreed/api/v4', 2) + `room/${token}/participants/resend-invitations`, { + await axios.post(generateOcsUrl('apps/spreed/api/v4/room/{token}/participants/resend-invitations', { token }), { attendeeId, }) } diff --git a/src/services/publicShareAuthService.js b/src/services/publicShareAuthService.js index caee86f25..0d044ee1d 100644 --- a/src/services/publicShareAuthService.js +++ b/src/services/publicShareAuthService.js @@ -30,7 +30,7 @@ import { generateOcsUrl } from '@nextcloud/router' * @throws {Exception} if the conversation token could not be got */ const getPublicShareAuthConversationToken = async function(shareToken) { - const response = await axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `publicshareauth`, { + const response = await axios.post(generateOcsUrl('apps/spreed/api/v1/publicshareauth'), { shareToken, }) return response.data.ocs.data.token diff --git a/src/services/settingsService.js b/src/services/settingsService.js index 7dc80c804..68adef35e 100644 --- a/src/services/settingsService.js +++ b/src/services/settingsService.js @@ -31,7 +31,7 @@ import BrowserStorage from './BrowserStorage' * @returns {Object} The axios response */ const setAttachmentFolder = async function(path) { - return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', { + return axios.post(generateOcsUrl('apps/spreed/api/v1/settings/user'), { key: 'attachment_folder', value: path, }) @@ -44,7 +44,7 @@ const setAttachmentFolder = async function(path) { * @returns {Object} The axios response */ const setReadStatusPrivacy = async function(privacy) { - return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', { + return axios.post(generateOcsUrl('apps/spreed/api/v1/settings/user'), { key: 'read_status_privacy', value: privacy, }) @@ -59,7 +59,7 @@ const setReadStatusPrivacy = async function(privacy) { * @returns {Object} The axios response */ const setSIPSettings = async function(sipGroups, sharedSecret, dialInInfo) { - return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'sip', { + return axios.post(generateOcsUrl('apps/spreed/api/v1/settings/sip'), { sipGroups, sharedSecret, dialInInfo, @@ -69,7 +69,7 @@ const setSIPSettings = async function(sipGroups, sharedSecret, dialInInfo) { const setPlaySounds = async function(isGuest, enabled) { const savableValue = enabled ? 'yes' : 'no' if (!isGuest) { - return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', { + return axios.post(generateOcsUrl('apps/spreed/api/v1/settings/user'), { key: 'play_sounds', value: savableValue, }) diff --git a/src/services/signalingService.js b/src/services/signalingService.js index a2806e820..137944072 100644 --- a/src/services/signalingService.js +++ b/src/services/signalingService.js @@ -27,7 +27,7 @@ import { generateOcsUrl } from '@nextcloud/router' * @param {object} options options */ const fetchSignalingSettings = async({ token }, options) => { - return axios.get(generateOcsUrl('apps/spreed/api/v2/signaling', 2) + 'settings', Object.assign(options, { + return axios.get(generateOcsUrl('apps/spreed/api/v2/signaling/settings'), Object.assign(options, { params: { token, }, @@ -35,11 +35,11 @@ const fetchSignalingSettings = async({ token }, options) => { } const pullSignalingMessages = async(token, options) => { - return axios.get(generateOcsUrl('apps/spreed/api/v2/signaling', 2) + token, options) + return axios.get(generateOcsUrl('apps/spreed/api/v2/signaling/{token}', { token }), options) } const getWelcomeMessage = async(serverId) => { - return axios.get(generateOcsUrl('apps/spreed/api/v2/signaling', 2) + 'welcome/' + serverId) + return axios.get(generateOcsUrl('apps/spreed/api/v2/signaling/welcome/{serverId}', { serverId })) } export { diff --git a/src/utils/signaling.js b/src/utils/signaling.js index 4a93b33a7..1c2a8e62e 100644 --- a/src/utils/signaling.js +++ b/src/utils/signaling.js @@ -242,7 +242,7 @@ Signaling.Base.prototype._joinCallSuccess = function(/* token */) { Signaling.Base.prototype.joinCall = function(token, flags) { return new Promise((resolve, reject) => { - axios.post(generateOcsUrl('apps/spreed/api/v4/call', 2) + token, { + axios.post(generateOcsUrl('apps/spreed/api/v4/call/{token}', { token }), { flags: flags, }) .then(function() { @@ -273,7 +273,7 @@ Signaling.Base.prototype.leaveCall = function(token, keepToken) { return } - axios.delete(generateOcsUrl('apps/spreed/api/v4/call', 2) + token) + axios.delete(generateOcsUrl('apps/spreed/api/v4/call/{token}', { token })) .then(function() { this._trigger('leaveCall', [token, keepToken]) this._leaveCallSuccess(token) @@ -362,7 +362,7 @@ Signaling.Internal.prototype._sendMessageWithCallback = function(ev) { } Signaling.Internal.prototype._sendMessages = function(messages) { - return axios.post(generateOcsUrl('apps/spreed/api/v1/signaling', 2) + this.currentRoomToken, { + return axios.post(generateOcsUrl('apps/spreed/api/v1/signaling/{token}', { token: this.currentRoomToken }), { messages: JSON.stringify(messages), }) } @@ -818,7 +818,7 @@ Signaling.Standalone.prototype.sendHello = function() { } else { // Already reconnected with a new session. this._forceReconnect = false - const url = generateOcsUrl('apps/spreed/api/v1/signaling', 2) + 'backend' + const url = generateOcsUrl('apps/spreed/api/v1/signaling/backend') msg = { 'type': 'hello', 'hello': { diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index e9a027026..e5776bdf8 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -153,7 +153,7 @@ export default { methods: { fetchRooms() { - axios.get(generateOcsUrl('apps/spreed/api/v4', 2) + 'room').then((response) => { + axios.get(generateOcsUrl('apps/spreed/api/v4/room')).then((response) => { const rooms = response.data.ocs.data const importantRooms = rooms.filter((conversation) => { return conversation.hasCall diff --git a/src/views/FlowPostToConversation.vue b/src/views/FlowPostToConversation.vue index a14029a49..195c61a10 100644 --- a/src/views/FlowPostToConversation.vue +++ b/src/views/FlowPostToConversation.vue @@ -77,7 +77,7 @@ export default { }, methods: { fetchRooms() { - axios.get(generateOcsUrl('/apps/spreed/api/v4', 2) + 'room').then((response) => { + axios.get(generateOcsUrl('/apps/spreed/api/v4/room')).then((response) => { this.roomOptions = response.data.ocs.data.filter(function(room) { return room.readOnly === CONVERSATION.STATE.READ_WRITE }) diff --git a/src/views/RoomSelector.spec.js b/src/views/RoomSelector.spec.js index 883376c84..5ea7e53d9 100644 --- a/src/views/RoomSelector.spec.js +++ b/src/views/RoomSelector.spec.js @@ -70,7 +70,7 @@ describe('RoomSelector.vue', () => { const wrapper = shallowMount(RoomSelector) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('/apps/spreed/api/v4', 2) + 'room' + generateOcsUrl('/apps/spreed/api/v4/room') ) mockAxios.mockResponse({ @@ -98,7 +98,7 @@ describe('RoomSelector.vue', () => { }) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('/apps/spreed/api/v4', 2) + 'room' + generateOcsUrl('/apps/spreed/api/v4/room') ) mockAxios.mockResponse({ @@ -121,7 +121,7 @@ describe('RoomSelector.vue', () => { const wrapper = shallowMount(RoomSelector) expect(mockAxios.get).toHaveBeenCalledWith( - generateOcsUrl('/apps/spreed/api/v4', 2) + 'room' + generateOcsUrl('/apps/spreed/api/v4/room') ) mockAxios.mockResponse({ diff --git a/src/views/RoomSelector.vue b/src/views/RoomSelector.vue index 44a8d568f..2f3260865 100644 --- a/src/views/RoomSelector.vue +++ b/src/views/RoomSelector.vue @@ -112,7 +112,7 @@ export default { }, methods: { fetchRooms() { - axios.get(generateOcsUrl('/apps/spreed/api/v4', 2) + 'room').then((response) => { + axios.get(generateOcsUrl('/apps/spreed/api/v4/room')).then((response) => { this.rooms = response.data.ocs.data.sort(this.sortConversations) this.loading = false }) |