Add contentiousContent support

This commit is contained in:
zkldi
2021-09-17 17:58:53 +01:00
parent 154e1030b5
commit 5ce8aed529
4 changed files with 20 additions and 2 deletions
@@ -0,0 +1,15 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import db from "external/mongo/db";
import MigrateRecords from "./migrate";
import { DEFAULT_USER_SETTINGS } from "server/router/api/v1/auth/auth";
function ConvertFn(c: any) {
return { userID: c.id, preferences: DEFAULT_USER_SETTINGS };
}
(async () => {
await MigrateRecords(db["user-settings"], "users", ConvertFn);
process.exit(0);
})();
@@ -30,7 +30,7 @@ function ConvertFn(c: any): PublicUserDocument {
}
(async () => {
await MigrateRecords(db, "users", ConvertFn);
await MigrateRecords(db.users, "users", ConvertFn);
process.exit(0);
})();
+2 -1
View File
@@ -76,9 +76,10 @@ export async function AddNewInvite(user: PublicUserDocument) {
return result;
}
const DEFAULT_USER_SETTINGS: UserSettings["preferences"] = {
export const DEFAULT_USER_SETTINGS: UserSettings["preferences"] = {
developerMode: false,
invisible: false,
contentiousContent: false,
};
export function HashPassword(plaintext: string) {
@@ -51,6 +51,7 @@ router.patch(
prValidate({
invisible: "*boolean",
developerMode: "*boolean",
contentiousContent: "*boolean",
}),
async (req, res) => {
const user = req[SYMBOL_TachiData]!.requestedUser!;
@@ -58,6 +59,7 @@ router.patch(
const preferences = {
invisible: req.body.invisible,
developerMode: req.body.developerMode,
contentiousContent: req.body.contentiousContent,
};
DeleteUndefinedProps(preferences);