Migrate old style tokens to new style because element-web doesn't soft-logoout on 4xx errors on /sync

This commit is contained in:
Kegan Dougal 2022-01-20 10:39:41 +00:00
parent 31f1810814
commit 842887982c
2 changed files with 4 additions and 1 deletions

View file

@ -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()),
}
}

View file

@ -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 {