fix export feature when not exporting saved posts

This commit is contained in:
teddit 2021-03-21 20:20:47 +01:00
parent dbe86258d7
commit d963c14155

View File

@ -1650,12 +1650,12 @@ module.exports = (app, redis, fetch, RedditAPI) => {
if(export_to_file === 'on') { if(export_to_file === 'on') {
res.setHeader('Content-disposition', 'attachment; filename=teddit_prefs.json') res.setHeader('Content-disposition', 'attachment; filename=teddit_prefs.json')
res.setHeader('Content-type', 'application/json') res.setHeader('Content-type', 'application/json')
return res.send(req.cookies) return res.send(export_data)
} }
let r = `${(Math.random().toString(36)+'00000000000000000').slice(2, 10+2).toUpperCase()}` let r = `${(Math.random().toString(36)+'00000000000000000').slice(2, 10+2).toUpperCase()}`
let key = `prefs_key:${r}` let key = `prefs_key:${r}`
redis.set(key, JSON.stringify(req.cookies), (error) => { redis.set(key, JSON.stringify(export_data), (error) => {
if(error) { if(error) {
console.error(`Error saving preferences to redis.`, error) console.error(`Error saving preferences to redis.`, error)
return res.redirect('/preferences') return res.redirect('/preferences')