Skip to content

Commit 2e3554e

Browse files
committed
fix(NextcloudBookmarks): Fix ticket failure retry mechanism
Signed-off-by: Marcel Klehr <[email protected]>
1 parent c57ef4d commit 2e3554e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/lib/adapters/NextcloudBookmarks.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -825,11 +825,12 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
825825
return json.ocs.data
826826
}
827827

828-
async sendRequest(verb:string, relUrl:string, type:string = null, body:any = null, returnRawResponse = false, headers = {}):Promise<any> {
828+
async sendRequest(verb:string, relUrl:string, type:string = null, originalBody:any = null, returnRawResponse = false, headers = {}):Promise<any> {
829829
const url = this.normalizeServerURL(this.server.url) + relUrl
830830
let res
831831
let timedOut = false
832832

833+
let body = originalBody
833834
if (type && type.includes('application/json')) {
834835
body = JSON.stringify(body)
835836
} else if (type && type.includes('application/x-www-form-urlencoded')) {
@@ -886,10 +887,10 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
886887
throw new RedirectError()
887888
}
888889

889-
if (res.status > 400 && res.status !== 423 && authString.startsWith('Bearer')) {
890+
if ((res.status === 401 || res.status === 403 || res.status === 404) && authString.startsWith('Bearer')) {
890891
this.ticket = null
891892
this.ticketTimestamp = 0
892-
return this.sendRequest(verb, relUrl, type, body, returnRawResponse, headers)
893+
return this.sendRequest(verb, relUrl, type, originalBody, returnRawResponse, headers)
893894
}
894895

895896
if (returnRawResponse) {
@@ -1003,7 +1004,7 @@ export default class NextcloudBookmarksAdapter implements Adapter, BulkImportRes
10031004
throw new RedirectError()
10041005
}
10051006

1006-
if (res.status > 400 && res.status !== 423 && authString.startsWith('Bearer')) {
1007+
if ((res.status === 401 || res.status === 403 || res.status === 404) && authString.startsWith('Bearer')) {
10071008
this.ticket = null
10081009
this.ticketTimestamp = 0
10091010
return this.sendRequestNative(verb, url, type, body, returnRawResponse, headers)

0 commit comments

Comments
 (0)