From 842887982c7f53aa6c48f1ab300c9eb42476dad3 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 20 Jan 2022 10:39:41 +0000 Subject: [PATCH] Migrate old style tokens to new style because element-web doesn't soft-logoout on 4xx errors on /sync --- syncapi/sync/requestpool.go | 2 +- syncapi/types/types.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/syncapi/sync/requestpool.go b/syncapi/sync/requestpool.go index 2eb50cd7f..ca35951a0 100644 --- a/syncapi/sync/requestpool.go +++ b/syncapi/sync/requestpool.go @@ -142,7 +142,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *userapi. if err != nil { if err == types.ErrMalformedSyncToken { return util.JSONResponse{ - Code: http.StatusUnauthorized, + Code: http.StatusBadRequest, JSON: jsonerror.InvalidArgumentValue(err.Error()), } } diff --git a/syncapi/types/types.go b/syncapi/types/types.go index 1e5f711e3..68c308d83 100644 --- a/syncapi/types/types.go +++ b/syncapi/types/types.go @@ -273,6 +273,9 @@ func NewStreamTokenFromString(tok string) (token StreamingToken, err error) { err = ErrMalformedSyncToken return } + // Migration: Remove everything after and including '.' - we previously had tokens like: + // s478_0_0_0_0_13.dl-0-2 but we have now removed partitioned stream positions + tok = strings.Split(tok, ".")[0] parts := strings.Split(tok[1:], "_") var positions [7]StreamPosition for i, p := range parts {