diff --git a/appinfo/routes.php b/appinfo/routes.php index 81f39d13fe..dfc8a7375c 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -43,30 +43,30 @@ ['name' => 'Attachment#getMediaFileMetadata', 'url' => '/mediaMetadata', 'verb' => 'GET'], /** @see Controller\SessionController::create() */ - ['name' => 'Session#create', 'url' => '/session/create', 'verb' => 'PUT'], + ['name' => 'Session#create', 'url' => '/session/{documentId}/create', 'verb' => 'PUT'], /** @see Controller\SessionController::save() */ - ['name' => 'Session#save', 'url' => '/session/save', 'verb' => 'POST'], + ['name' => 'Session#save', 'url' => '/session/{documentId}/save', 'verb' => 'POST'], /** @see Controller\SessionController::sync() */ - ['name' => 'Session#sync', 'url' => '/session/sync', 'verb' => 'POST'], + ['name' => 'Session#sync', 'url' => '/session/{documentId}/sync', 'verb' => 'POST'], /** @see Controller\SessionController::push() */ - ['name' => 'Session#push', 'url' => '/session/push', 'verb' => 'POST'], + ['name' => 'Session#push', 'url' => '/session/{documentId}/push', 'verb' => 'POST'], /** @see Controller\SessionController::close() */ - ['name' => 'Session#close', 'url' => '/session/close', 'verb' => 'POST'], + ['name' => 'Session#close', 'url' => '/session/{documentId}/close', 'verb' => 'POST'], /** @see Controller\SessionController::mention() */ - ['name' => 'Session#mention', 'url' => '/session/mention', 'verb' => 'PUT'], + ['name' => 'Session#mention', 'url' => '/session/{documentId}/mention', 'verb' => 'PUT'], /** @see Controller\PublicSessionController::create() */ - ['name' => 'PublicSession#create', 'url' => '/public/session/create', 'verb' => 'PUT'], + ['name' => 'PublicSession#create', 'url' => '/public/session/{documentId}/create', 'verb' => 'PUT'], /** @see Controller\PublicSessionController::updateSession() */ - ['name' => 'PublicSession#updateSession', 'url' => '/public/session', 'verb' => 'POST'], + ['name' => 'PublicSession#updateSession', 'url' => '/public/session/{documentId}/session', 'verb' => 'POST'], /** @see Controller\PublicSessionController::save() */ - ['name' => 'PublicSession#save', 'url' => '/public/session/save', 'verb' => 'POST'], + ['name' => 'PublicSession#save', 'url' => '/public/session/{documentId}/save', 'verb' => 'POST'], /** @see Controller\PublicSessionController::sync() */ - ['name' => 'PublicSession#sync', 'url' => '/public/session/sync', 'verb' => 'POST'], + ['name' => 'PublicSession#sync', 'url' => '/public/session/{documentId}/sync', 'verb' => 'POST'], /** @see Controller\PublicSessionController::push() */ - ['name' => 'PublicSession#push', 'url' => '/public/session/push', 'verb' => 'POST'], + ['name' => 'PublicSession#push', 'url' => '/public/session/{documentId}/push', 'verb' => 'POST'], /** @see Controller\PublicSessionController::close() */ - ['name' => 'PublicSession#close', 'url' => '/public/session/close', 'verb' => 'POST'], + ['name' => 'PublicSession#close', 'url' => '/public/session/{documentId}/close', 'verb' => 'POST'], /** @see Controller\SettingsController::updateConfig() */ ['name' => 'Settings#updateConfig', 'url' => '/settings', 'verb' => 'POST'], diff --git a/cypress/e2e/api/SyncServiceProvider.spec.js b/cypress/e2e/api/SyncServiceProvider.spec.js index c8ee4d7bd3..aae87849b4 100644 --- a/cypress/e2e/api/SyncServiceProvider.spec.js +++ b/cypress/e2e/api/SyncServiceProvider.spec.js @@ -77,9 +77,9 @@ describe('Sync service provider', function() { it('recovers from a dropped message', function() { const sourceMap = this.source.getMap() const targetMap = this.target.getMap() - cy.intercept({ method: 'POST', url: '**/apps/text/session/push' }) + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/push' }) .as('push') - cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }) + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/sync' }) .as('sync') cy.wait('@push') cy.then(() => { @@ -95,7 +95,7 @@ describe('Sync service provider', function() { }) cy.intercept({ method: 'POST', - url: '**/apps/text/session/push', + url: '**/apps/text/session/*/push', }, req => { if (req.body.steps) { req.reply({ forceNetworkError: true }) @@ -114,7 +114,7 @@ describe('Sync service provider', function() { }) cy.intercept({ method: 'POST', - url: '**/apps/text/session/push', + url: '**/apps/text/session/*/push', }, req => { if (req.body.steps) { req.alias = 'alive' @@ -143,9 +143,9 @@ describe('Sync service provider', function() { it.skip('is not too chatty', function() { const sourceMap = this.source.getMap() const targetMap = this.target.getMap() - cy.intercept({ method: 'POST', url: '**/apps/text/session/push' }) + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/push' }) .as('push') - cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }) + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/sync' }) .as('sync') cy.wait('@push') cy.then(() => { diff --git a/cypress/e2e/directediting.spec.js b/cypress/e2e/directediting.spec.js index 911ca13b68..e798bf3f99 100644 --- a/cypress/e2e/directediting.spec.js +++ b/cypress/e2e/directediting.spec.js @@ -62,9 +62,9 @@ describe('direct editing', function() { }) it('Open an existing file, edit it', () => { - cy.intercept({ method: 'POST', url: '**/session/close' }).as('closeRequest') - cy.intercept({ method: 'POST', url: '**/session/push' }).as('push') - cy.intercept({ method: 'POST', url: '**/session/sync' }).as('sync') + cy.intercept({ method: 'POST', url: '**/session/*/close' }).as('closeRequest') + cy.intercept({ method: 'POST', url: '**/session/*/push' }).as('push') + cy.intercept({ method: 'POST', url: '**/session/*/sync' }).as('sync') createDirectEditingLink(user, 'empty.md') .then((token) => { @@ -90,9 +90,9 @@ describe('direct editing', function() { }) it('Create a file, edit it', () => { - cy.intercept({ method: 'POST', url: '**/session/close' }).as('closeRequest') - cy.intercept({ method: 'POST', url: '**/session/push' }).as('push') - cy.intercept({ method: 'POST', url: '**/session/sync' }).as('sync') + cy.intercept({ method: 'POST', url: '**/session/*/close' }).as('closeRequest') + cy.intercept({ method: 'POST', url: '**/session/*/push' }).as('push') + cy.intercept({ method: 'POST', url: '**/session/*/sync' }).as('sync') createDirectEditingLinkForNewFile(user, 'newfile.md') .then((token) => { @@ -119,9 +119,9 @@ describe('direct editing', function() { }) it('Open an existing plain text file, edit it', () => { - cy.intercept({ method: 'POST', url: '**/session/close' }).as('closeRequest') - cy.intercept({ method: 'POST', url: '**/session/push' }).as('push') - cy.intercept({ method: 'POST', url: '**/session/sync' }).as('sync') + cy.intercept({ method: 'POST', url: '**/session/*/close' }).as('closeRequest') + cy.intercept({ method: 'POST', url: '**/session/*/push' }).as('push') + cy.intercept({ method: 'POST', url: '**/session/*/sync' }).as('sync') createDirectEditingLink(user, 'empty.txt') .then((token) => { diff --git a/cypress/e2e/nodes/FrontMatter.spec.js b/cypress/e2e/nodes/FrontMatter.spec.js index 2b81629d62..c681385c95 100644 --- a/cypress/e2e/nodes/FrontMatter.spec.js +++ b/cypress/e2e/nodes/FrontMatter.spec.js @@ -69,7 +69,7 @@ describe('Front matter support', function() { expect(pre.length === 1) }) cy.closeFile() - cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }).as('sync') + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/sync' }).as('sync') cy.openFile('frontmatter.md') cy.wait('@sync') cy.wait('@sync') diff --git a/cypress/e2e/share.spec.js b/cypress/e2e/share.spec.js index 6a6eecd8a0..98f42b53ce 100644 --- a/cypress/e2e/share.spec.js +++ b/cypress/e2e/share.spec.js @@ -135,7 +135,7 @@ describe('Open test.md in viewer', function() { }) it('makes use of the file id', function() { - cy.intercept({ method: 'PUT', url: '**/apps/text/public/session/create' }) + cy.intercept({ method: 'PUT', url: '**/apps/text/public/session/*/create' }) .as('create') cy.shareFile('/test2.md', { edit: true }) .then((token) => { diff --git a/cypress/e2e/sync.spec.js b/cypress/e2e/sync.spec.js index 1f5abb6581..01a68ab703 100644 --- a/cypress/e2e/sync.spec.js +++ b/cypress/e2e/sync.spec.js @@ -33,8 +33,8 @@ describe('Sync', () => { cy.login(user) cy.uploadTestFile('test.md') cy.visit('/apps/files') - cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }).as('sync') - cy.intercept({ method: 'POST', url: '**/apps/text/session/save' }).as('save') + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/sync' }).as('sync') + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/save' }).as('save') cy.openTestFile() cy.getContent().find('h2').should('contain', 'Hello world') cy.getContent().type('{moveToEnd}* Saving the doc saves the doc state{enter}') @@ -63,7 +63,7 @@ describe('Sync', () => { it('recovers from a short lost connection', () => { let reconnect = false - cy.intercept('**/apps/text/session/*', (req) => { + cy.intercept('**/apps/text/session/*/*', (req) => { if (reconnect) { req.continue() req.alias = 'alive' @@ -79,7 +79,7 @@ describe('Sync', () => { reconnect = true }) cy.wait('@alive', { timeout: 30000 }) - cy.intercept({ method: 'POST', url: '**/apps/text/session/sync' }) + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/sync' }) .as('syncAfterRecovery') cy.wait('@syncAfterRecovery', { timeout: 30000 }) cy.get('#editor-container .document-status', { timeout: 30000 }) @@ -97,7 +97,7 @@ describe('Sync', () => { it('recovers from a lost and closed connection', () => { let reconnect = false - cy.intercept('**/apps/text/session/*', (req) => { + cy.intercept('**/apps/text/session/*/*', (req) => { if (req.url.includes('close') || req.url.includes('create') || reconnect) { req.continue() req.alias = 'syncAfterRecovery' @@ -128,7 +128,7 @@ describe('Sync', () => { it('passes the doc content from one session to the next', () => { cy.closeFile() - cy.intercept({ method: 'PUT', url: '**/apps/text/session/create' }) + cy.intercept({ method: 'PUT', url: '**/apps/text/session/*/create' }) .as('create') cy.openTestFile() cy.wait('@create', { timeout: 10000 }) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index daf04d01d1..a39fbbe344 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -334,7 +334,7 @@ Cypress.Commands.add('openFileInShare', fileName => { }) Cypress.Commands.add('closeFile', (params = {}) => { - cy.intercept({ method: 'POST', url: '**/apps/text/session/close' }) + cy.intercept({ method: 'POST', url: '**/apps/text/session/*/close' }) .as('close') cy.get('#viewer .modal-header button.header-close').click(params) cy.get('#viewer .modal-header').should('not.exist') diff --git a/src/services/SessionApi.js b/src/services/SessionApi.js index 7380401c96..8c592a7bd2 100644 --- a/src/services/SessionApi.js +++ b/src/services/SessionApi.js @@ -39,7 +39,7 @@ class SessionApi { } open({ fileId }) { - return axios.put(this.#url('session/create'), { + return axios.put(this.#url(`session/${fileId}/create`), { fileId, filePath: this.#options.filePath, token: this.#options.shareToken, @@ -109,7 +109,7 @@ export class Connection { } sync({ version }) { - return this.#post(this.#url('session/sync'), { + return this.#post(this.#url(`session/${this.#document.id}/sync`), { ...this.#defaultParams, filePath: this.#options.filePath, version, @@ -117,7 +117,7 @@ export class Connection { } save({ version, autosaveContent, documentState, force, manualSave }) { - return this.#post(this.#url('session/save'), { + return this.#post(this.#url(`session/${this.#document.id}/save`), { ...this.#defaultParams, filePath: this.#options.filePath, version, @@ -129,7 +129,7 @@ export class Connection { } push({ steps, version, awareness }) { - return this.#post(this.#url('session/push'), { + return this.#post(this.#url(`session/${this.#document.id}/push`), { ...this.#defaultParams, filePath: this.#options.filePath, steps, @@ -140,7 +140,7 @@ export class Connection { // TODO: maybe return a new connection here so connections have immutable state update(guestName) { - return this.#post(this.#url('session'), { + return this.#post(this.#url(`session/${this.#document.id}/session`), { ...this.#defaultParams, guestName, }).then(({ data }) => { @@ -173,7 +173,7 @@ export class Connection { } close() { - const promise = this.#post(this.#url('session/close'), this.#defaultParams) + const promise = this.#post(this.#url(`session/${this.#document.id}/close`), this.#defaultParams) this.closed = true return promise }