diff options
Diffstat (limited to '')
-rw-r--r-- | lib/history.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/history.js b/lib/history.js index f46ff49f..c7d2472c 100644 --- a/lib/history.js +++ b/lib/history.js @@ -1,6 +1,7 @@ 'use strict' // history // external modules +var LZString = require('lz-string') // core var config = require('./config') @@ -27,7 +28,20 @@ function getHistory (userid, callback) { } var history = {} if (user.history) { - history = parseHistoryToObject(JSON.parse(user.history)) + history = JSON.parse(user.history) + // migrate LZString encoded note id to base64url encoded note id + for (let i = 0, l = history.length; i < l; i++) { + try { + let id = LZString.decompressFromBase64(history[i].id) + if (id && models.Note.checkNoteIdValid(id)) { + history[i].id = models.Note.encodeNoteId(id) + } + } catch (err) { + // most error here comes from LZString, ignore + logger.error(err) + } + } + history = parseHistoryToObject(history) } if (config.debug) { logger.info('read history success: ' + user.id) |