mirror of
https://github.com/filecoin-project/slate.git
synced 2024-12-25 18:13:10 +03:00
feat(db/users): add settings column
This commit is contained in:
parent
d57ee64c09
commit
da00d27a4c
@ -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({
|
||||
|
@ -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.`);
|
||||
|
Loading…
Reference in New Issue
Block a user