#319 profile schema v2 - further fixes

This commit is contained in:
Andrea Vos 2022-09-24 19:26:56 +02:00
parent 1ee749da9f
commit e2fe67f127
3 changed files with 53 additions and 23 deletions

View File

@ -23,6 +23,7 @@ stop:
deploy: install
yarn build
node server/migrate.js
echo "\ncaches.keys().then(cs=>cs.forEach(c=>caches.delete(c)))" >> static/sw.js
ln -sfn ../data/img ./static/img-local
ln -sfn ../data/docs ./static/docs-local

View File

@ -183,6 +183,11 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => {
req.body = upgradeToV2(req.body);
}
if (!Array.isArray(req.body.customFlags)) {
// no idea WTF is happening here, but somehow we got values like {"0": ..., "1": ..., ...}
req.body.customFlags = Object.values(req.body.customFlags);
}
// TODO just make it a transaction...
const ids = (await req.db.all(SQL`SELECT * FROM profiles WHERE userId = ${req.user.id} AND locale = ${global.config.locale}`)).map(row => row.id);
if (ids.length) {

File diff suppressed because one or more lines are too long