diff --git a/pages/api/users/update.js b/pages/api/users/update.js index 3f0e1c5f..5c73e697 100644 --- a/pages/api/users/update.js +++ b/pages/api/users/update.js @@ -1,7 +1,6 @@ import * as Environment from "~/node_common/environment"; import * as Data from "~/node_common/data"; import * as Utilities from "~/node_common/utilities"; -import * as Serializers from "~/node_common/serializers"; import * as Validations from "~/common/validations"; import * as Social from "~/node_common/social"; import * as ViewerManager from "~/node_common/managers/viewer"; @@ -38,6 +37,10 @@ export default async (req, res) => { } } + if (updates.settings) { + updates.settings = { ...user.settings, ...updates.settings }; + } + if (updates.email && updates.email !== user.email) { if (!Validations.email(updates.email)) { return res.status(400).send({ @@ -108,10 +111,7 @@ export default async (req, res) => { } try { - const configResponse = await b.buckets.setDefaultArchiveConfig( - b.bucketKey, - req.body.data.config - ); + await b.buckets.setDefaultArchiveConfig(b.bucketKey, req.body.data.config); } catch (e) { Logging.error(e); Social.sendTextileSlackMessage({ diff --git a/scripts/adjust.js b/scripts/adjust.js index 6b2b293e..56e76b7d 100644 --- a/scripts/adjust.js +++ b/scripts/adjust.js @@ -42,7 +42,18 @@ const addSlateCoverImage = db.schema.table("slates", function (table) { table.jsonb("coverImage").nullable(); }); -Promise.all([addSlateCoverImage]); +const addSettingsColumnToUsersTable = db.schema + .table("users", (table) => { + table.jsonb("settings").defaultTo("{}"); + }) + .then(() => + db("users").update( + "settings", + db.raw("jsonb_build_object('filecoin', users.data -> 'settings' )") + ) + ); + +Promise.all([addSettingsColumnToUsersTable]); Logging.log(`FINISHED: adjust.js`); Logging.log(` CTRL +C to return to terminal.`);