Loosen TrollCall requirements, fix some dumbshit

This commit is contained in:
MeowcaTheoRange 2023-07-19 12:43:59 -05:00
parent e1a86bd50b
commit b955477231
7 changed files with 88 additions and 67 deletions

View file

@ -20,7 +20,7 @@ export async function ServerTrollToClientTroll(
serverTroll.falseSign != null serverTroll.falseSign != null
? TrueSign[serverTroll.falseSign] ? TrueSign[serverTroll.falseSign]
: null, : null,
class: Class[serverTroll.class], class: serverTroll.class ? Class[serverTroll.class] : null,
owners: [], owners: [],
flairs: cutArray(flairs) flairs: cutArray(flairs)
}; };

View file

@ -15,7 +15,7 @@ export async function ServerUserToClientUser(
); );
let clientUser: ClientUser = { let clientUser: ClientUser = {
...sanitizedUser, ...sanitizedUser,
trueSign: TrueSign[serverUser.trueSign], trueSign: serverUser.trueSign ? TrueSign[serverUser.trueSign] : null,
flairs: cutArray(flairs), flairs: cutArray(flairs),
updatedDate: serverUser.updatedDate?.getTime() updatedDate: serverUser.updatedDate?.getTime()
}; };

View file

@ -53,8 +53,10 @@ export default async function handler(
const serverUser = SubmitUserToServerUser(validatedUser); const serverUser = SubmitUserToServerUser(validatedUser);
if (serverUser.code === "") if (serverUser.code === "")
serverUser.code = checkExistingUser.code || nanoid(16); serverUser.code = checkExistingUser.code || nanoid(16);
if (!compareLevels(getLevel(checkExistingUser), "SUPPORTER")) if (!compareLevels(getLevel(checkExistingUser), "SUPPORTER")) {
serverUser.bgimage = null; serverUser.bgimage = null;
serverUser.css = null;
}
const bothUsers = MergeServerUsers(checkExistingUser, serverUser); const bothUsers = MergeServerUsers(checkExistingUser, serverUser);
const newUser = await changeUser(bothUsers); const newUser = await changeUser(bothUsers);
if (newUser == null) return res.status(503).end(); if (newUser == null) return res.status(503).end();

View file

@ -1,4 +1,3 @@
import { ColorSchema } from "@/types/assist/color";
import * as yup from "yup"; import * as yup from "yup";
import { ClassKeys, TrueSignKeys } from "../assist/extended_zodiac"; import { ClassKeys, TrueSignKeys } from "../assist/extended_zodiac";
import { PolicySchema } from "../assist/generics"; import { PolicySchema } from "../assist/generics";
@ -13,13 +12,15 @@ export const SubmitTrollSchema = yup
.string() .string()
.required() .required()
.matches(/^[A-z]+$/, "Letters only") .matches(/^[A-z]+$/, "Letters only")
.length(6) .min(1)
.max(24)
.lowercase(), .lowercase(),
yup yup
.string() .string()
.required() .required()
.matches(/^[A-z]+$/, "Letters only") .matches(/^[A-z]+$/, "Letters only")
.length(6) .min(1)
.max(24)
.lowercase() .lowercase()
]) ])
.required(), .required(),
@ -77,28 +78,17 @@ export const SubmitTrollSchema = yup
.max(30), .max(30),
// Personal // Personal
preferences: yup preferences: yup.object({
.object({
love: yup love: yup
.array() .array()
.of(yup.string().required().min(5).max(100)) .of(yup.string().required().min(5).max(500))
.required()
.min(3)
.max(10), .max(10),
hate: yup hate: yup
.array() .array()
.of(yup.string().required().min(5).max(100)) .of(yup.string().required().min(5).max(500))
.required()
.min(3)
.max(10) .max(10)
}) }),
.required(), facts: yup.array().of(yup.string().required().min(5).max(500)).max(10),
facts: yup
.array()
.of(yup.string().required().min(5).max(100))
.required()
.min(3)
.max(10),
// Hiveswap identity // Hiveswap identity
trueSign: yup.string().required().oneOf(TrueSignKeys), trueSign: yup.string().required().oneOf(TrueSignKeys),
@ -108,21 +98,27 @@ export const SubmitTrollSchema = yup
.transform(v => { .transform(v => {
return v === "" ? null : v; return v === "" ? null : v;
}) })
.oneOf(TrueSignKeys), // "Keelez Bunbat" .oneOf(TrueSignKeys),
prioritizeTrueSign: yup.boolean().default(false), class: yup.string().oneOf(ClassKeys),
class: yup.string().required().oneOf(ClassKeys),
// Trollian // Trollian
username: yup username: yup.string().max(100),
.string() textColor: yup
.required() .tuple([
.matches( yup.number().min(0).max(255),
/^(([a-z])[a-z]+)(([A-Z])[a-z]+)$/, yup.number().min(0).max(255),
"Username must match Pesterchum formatting." yup.number().min(0).max(255)
), ])
textColor: ColorSchema.notRequired(), // default to trueSign color if undefined, .notRequired(), // default to trueSign color if undefined,
pageColor: yup
.tuple([
yup.number().min(0).max(255),
yup.number().min(0).max(255),
yup.number().min(0).max(255)
])
.notRequired(), // colors the page.
quirks: SubmitQuirkHolderSchema.required(), // DO NOT HANDLE RIGHT NOW. quirks: SubmitQuirkHolderSchema.required(), // DO NOT HANDLE RIGHT NOW.
quotes: yup.array().of(yup.string().max(1000)).required(), quotes: yup.array().of(yup.string().max(1000)).max(20),
// Physical stuff // Physical stuff
species: yup species: yup
@ -134,15 +130,13 @@ export const SubmitTrollSchema = yup
age: yup.number().required().positive(), // Sweeps age: yup.number().required().positive(), // Sweeps
images: yup.array().of(yup.string().required().url()).required(), images: yup.array().of(yup.string().required().url()).required(),
// Meta stuff // Meta stuff
policies: yup policies: yup.object({
.object({
fanart: PolicySchema.required(), fanart: PolicySchema.required(),
fanartOthers: PolicySchema.required(), fanartOthers: PolicySchema.required(),
kinning: PolicySchema.required(), kinning: PolicySchema.required(),
shipping: PolicySchema.required(), shipping: PolicySchema.required(),
fanfiction: PolicySchema.required() fanfiction: PolicySchema.required()
}) })
.required()
// owners: yup.array().of(yup.string().required()).required().min(1), // owners: yup.array().of(yup.string().required()).required().min(1),
// flairs: yup.array().of(yup.mixed()).required().ensure(), // flairs: yup.array().of(yup.mixed()).required().ensure(),
}) })
@ -157,12 +151,14 @@ export const PartialTrollSchema = yup
yup yup
.string() .string()
.matches(/^[A-z]+$/, "Letters only") .matches(/^[A-z]+$/, "Letters only")
.length(6) .min(1)
.max(24)
.lowercase(), .lowercase(),
yup yup
.string() .string()
.matches(/^[A-z]+$/, "Letters only") .matches(/^[A-z]+$/, "Letters only")
.length(6) .min(1)
.max(24)
.lowercase() .lowercase()
]), ]),
description: yup.string().max(10000), description: yup.string().max(10000),
@ -209,10 +205,10 @@ export const PartialTrollSchema = yup
// Personal // Personal
preferences: yup.object({ preferences: yup.object({
love: yup.array().of(yup.string().min(5).max(100)).min(3).max(10), love: yup.array().of(yup.string().min(5).max(500)).max(10),
hate: yup.array().of(yup.string().min(5).max(100)).min(3).max(10) hate: yup.array().of(yup.string().min(5).max(500)).max(10)
}), }),
facts: yup.array().of(yup.string().min(5).max(100)).min(3).max(10), facts: yup.array().of(yup.string().min(5).max(500)).max(10),
// Hiveswap identity // Hiveswap identity
trueSign: yup.string().oneOf(TrueSignKeys), trueSign: yup.string().oneOf(TrueSignKeys),
@ -223,21 +219,20 @@ export const PartialTrollSchema = yup
return v === "" ? null : v; return v === "" ? null : v;
}) })
.oneOf(TrueSignKeys), // "Keelez Bunbat" .oneOf(TrueSignKeys), // "Keelez Bunbat"
prioritizeTrueSign: yup.boolean(),
class: yup.string().oneOf(ClassKeys), class: yup.string().oneOf(ClassKeys),
// Trollian // Trollian
username: yup username: yup.string().max(100),
.string()
.matches(
/^(([a-z])[a-z]+)(([A-Z])[a-z]+)$/,
"Username must match Pesterchum formatting."
),
textColor: yup.tuple([ textColor: yup.tuple([
yup.number().min(0).max(255), yup.number().min(0).max(255),
yup.number().min(0).max(255), yup.number().min(0).max(255),
yup.number().min(0).max(255) yup.number().min(0).max(255)
]), ]),
pageColor: yup.tuple([
yup.number().min(0).max(255),
yup.number().min(0).max(255),
yup.number().min(0).max(255)
]),
quirks: PartialQuirkHolderSchema, // DO NOT HANDLE RIGHT NOW. quirks: PartialQuirkHolderSchema, // DO NOT HANDLE RIGHT NOW.
quotes: yup.array().of(yup.string().max(1000)), quotes: yup.array().of(yup.string().max(1000)),

View file

@ -1,6 +1,6 @@
import * as yup from "yup"; import * as yup from "yup";
import { ColorSchema } from "../assist/color";
import { TrueSignKeys } from "../assist/extended_zodiac"; import { TrueSignKeys } from "../assist/extended_zodiac";
import { PolicySchema } from "../assist/generics";
export const SubmitUserSchema = yup export const SubmitUserSchema = yup
.object({ .object({
@ -13,7 +13,7 @@ export const SubmitUserSchema = yup
.lowercase(), .lowercase(),
description: yup.string().max(10000).ensure(), description: yup.string().max(10000).ensure(),
url: yup.string().notRequired().url(), url: yup.string().notRequired().url(),
trueSign: yup.string().required().oneOf(TrueSignKeys), trueSign: yup.string().notRequired().oneOf(TrueSignKeys),
pronouns: yup pronouns: yup
.array() .array()
.of( .of(
@ -45,9 +45,25 @@ export const SubmitUserSchema = yup
) )
.required() .required()
.min(1), .min(1),
color: ColorSchema.required(), color: yup
.tuple([
yup.number().min(0).max(255),
yup.number().min(0).max(255),
yup.number().min(0).max(255)
])
.notRequired(),
policies: yup
.object({
fanart: PolicySchema.required(),
fanartOthers: PolicySchema.required(),
kinning: PolicySchema.required(),
shipping: PolicySchema.required(),
fanfiction: PolicySchema.required()
})
.required(),
pfp: yup.string().notRequired().url(), pfp: yup.string().notRequired().url(),
bgimage: yup.string().notRequired().url(), bgimage: yup.string().notRequired().url(),
css: yup.string().notRequired(),
code: yup.string().notRequired().max(256, "Too secure!!") code: yup.string().notRequired().max(256, "Too secure!!")
// flairs: yup.array().of(ClientFlairSchema).required(), // flairs: yup.array().of(ClientFlairSchema).required(),
}) })
@ -102,8 +118,16 @@ export const PartialUserSchema = yup
yup.number().min(0).max(255), yup.number().min(0).max(255),
yup.number().min(0).max(255) yup.number().min(0).max(255)
]), ]),
policies: yup.object({
fanart: PolicySchema,
fanartOthers: PolicySchema,
kinning: PolicySchema,
shipping: PolicySchema,
fanfiction: PolicySchema
}),
pfp: yup.string().url(), pfp: yup.string().url(),
bgimage: yup.string().url(), bgimage: yup.string().url(),
css: yup.string(),
code: yup.string().max(256, "Too secure!!") code: yup.string().max(256, "Too secure!!")
// flairs: yup.array().of(ClientFlairSchema).required(), // flairs: yup.array().of(ClientFlairSchema).required(),
}) })

View file

@ -20,9 +20,9 @@ export const ClientTrollSchema = SubmitTrollSchema.shape({
owners: yup.array().of(ClientUserSchema.required()).required().min(1), owners: yup.array().of(ClientUserSchema.required()).required().min(1),
flairs: yup.array().of(ClientFlairSchema.required()).required(), flairs: yup.array().of(ClientFlairSchema.required()).required(),
quirks: ServerQuirkHolderSchema.required(), quirks: ServerQuirkHolderSchema.required(),
trueSign: TrueSignSchema.required(), trueSign: TrueSignSchema.notRequired(),
falseSign: TrueSignSchema.notRequired(), falseSign: TrueSignSchema.notRequired(),
class: ClassSchema.required() class: ClassSchema.notRequired()
}); });
export interface ClientTroll extends yup.InferType<typeof ClientTrollSchema> { export interface ClientTroll extends yup.InferType<typeof ClientTrollSchema> {

View file

@ -15,7 +15,7 @@ export type ServerUser = WithId<yup.InferType<typeof ServerUserSchema>>;
export const ClientUserSchema = SubmitUserSchema.shape({ export const ClientUserSchema = SubmitUserSchema.shape({
flairs: yup.array().of(ClientFlairSchema.required()).required(), flairs: yup.array().of(ClientFlairSchema.required()).required(),
trueSign: TrueSignSchema.required(), trueSign: TrueSignSchema.notRequired(),
updatedDate: yup.number().notRequired() updatedDate: yup.number().notRequired()
}); });