Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/text.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2021-01-21 18:10:41 +0300
committerJulius Härtl <jus@bitgrid.net>2021-01-21 18:10:41 +0300
commitc5d38f3ef9b60db2d936c62eba71cbe67d67c731 (patch)
tree12809b91cd21e6d806aa42086741c5a76cbd8fc6
parentd8e97f692fc16ca237fcda5888d3a2007a064270 (diff)
Fix uncatched errors on push stepsbugfix/1311
Signed-off-by: Julius Härtl <jus@bitgrid.net>
-rw-r--r--lib/Service/ApiService.php4
-rw-r--r--src/services/PollingBackend.js15
2 files changed, 14 insertions, 5 deletions
diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php
index b7148c6d1..4f0370d0b 100644
--- a/lib/Service/ApiService.php
+++ b/lib/Service/ApiService.php
@@ -138,6 +138,10 @@ class ApiService {
*/
public function push($documentId, $sessionId, $sessionToken, $version, $steps, $token = null): DataResponse {
$session = $this->sessionService->getSession($documentId, $sessionId, $sessionToken);
+ if ($session === false || !$this->sessionService->isValidSession($documentId, $sessionId, $sessionToken)) {
+ return new DataResponse([], 403);
+ }
+
$file = $this->documentService->getFileForSession($session, $token);
if ($this->sessionService->isValidSession($documentId, $sessionId, $sessionToken) && !$this->documentService->isReadOnly($file, $token)) {
try {
diff --git a/src/services/PollingBackend.js b/src/services/PollingBackend.js
index 42349451d..31960223d 100644
--- a/src/services/PollingBackend.js
+++ b/src/services/PollingBackend.js
@@ -214,15 +214,20 @@ class PollingBackend {
this.lock = false
this.fetchSteps()
}).catch((e) => {
- console.error('failed to apply steps due to collission, retrying')
this.lock = false
if (!e.response || e.code === 'ECONNABORTED') {
this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, {})
return
- } else if (e.response.status === 403 && e.response.data.document.currentVersion === this._authority.document.currentVersion) {
- // Only emit conflict event if we have synced until the latest version
- this._authority.emit('error', ERROR_TYPE.PUSH_FAILURE, {})
- OC.Notification.showTemporary('Changes could not be sent yet')
+ } else if (e.response.status === 403) {
+ this._authority.emit('error', ERROR_TYPE.CONNECTION_FAILED, { retry: false })
+ return
+ } else if (e.response.status === 412) {
+ console.error('failed to apply steps due to collission, retrying', e)
+ if (e.response?.data?.document?.currentVersion === this._authority.document.currentVersion) {
+ // Only emit conflict event if we have synced until the latest version
+ this._authority.emit('error', ERROR_TYPE.PUSH_FAILURE, {})
+ OC.Notification.showTemporary('Changes could not be sent yet')
+ }
}
this.fetchSteps()