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
? TrueSign[serverTroll.falseSign]
: null,
class: Class[serverTroll.class],
class: serverTroll.class ? Class[serverTroll.class] : null,
owners: [],
flairs: cutArray(flairs)
};

View file

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

View file

@ -53,8 +53,10 @@ export default async function handler(
const serverUser = SubmitUserToServerUser(validatedUser);
if (serverUser.code === "")
serverUser.code = checkExistingUser.code || nanoid(16);
if (!compareLevels(getLevel(checkExistingUser), "SUPPORTER"))
if (!compareLevels(getLevel(checkExistingUser), "SUPPORTER")) {
serverUser.bgimage = null;
serverUser.css = null;
}
const bothUsers = MergeServerUsers(checkExistingUser, serverUser);
const newUser = await changeUser(bothUsers);
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 { ClassKeys, TrueSignKeys } from "../assist/extended_zodiac";
import { PolicySchema } from "../assist/generics";
@ -13,13 +12,15 @@ export const SubmitTrollSchema = yup
.string()
.required()
.matches(/^[A-z]+$/, "Letters only")
.length(6)
.min(1)
.max(24)
.lowercase(),
yup
.string()
.required()
.matches(/^[A-z]+$/, "Letters only")
.length(6)
.min(1)
.max(24)
.lowercase()
])
.required(),
@ -77,28 +78,17 @@ export const SubmitTrollSchema = yup
.max(30),
// Personal
preferences: yup
.object({
love: yup
.array()
.of(yup.string().required().min(5).max(100))
.required()
.min(3)
.max(10),
hate: yup
.array()
.of(yup.string().required().min(5).max(100))
.required()
.min(3)
.max(10)
})
.required(),
facts: yup
.array()
.of(yup.string().required().min(5).max(100))
.required()
.min(3)
.max(10),
preferences: yup.object({
love: yup
.array()
.of(yup.string().required().min(5).max(500))
.max(10),
hate: yup
.array()
.of(yup.string().required().min(5).max(500))
.max(10)
}),
facts: yup.array().of(yup.string().required().min(5).max(500)).max(10),
// Hiveswap identity
trueSign: yup.string().required().oneOf(TrueSignKeys),
@ -108,21 +98,27 @@ export const SubmitTrollSchema = yup
.transform(v => {
return v === "" ? null : v;
})
.oneOf(TrueSignKeys), // "Keelez Bunbat"
prioritizeTrueSign: yup.boolean().default(false),
class: yup.string().required().oneOf(ClassKeys),
.oneOf(TrueSignKeys),
class: yup.string().oneOf(ClassKeys),
// Trollian
username: yup
.string()
.required()
.matches(
/^(([a-z])[a-z]+)(([A-Z])[a-z]+)$/,
"Username must match Pesterchum formatting."
),
textColor: ColorSchema.notRequired(), // default to trueSign color if undefined,
username: yup.string().max(100),
textColor: yup
.tuple([
yup.number().min(0).max(255),
yup.number().min(0).max(255),
yup.number().min(0).max(255)
])
.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.
quotes: yup.array().of(yup.string().max(1000)).required(),
quotes: yup.array().of(yup.string().max(1000)).max(20),
// Physical stuff
species: yup
@ -134,15 +130,13 @@ export const SubmitTrollSchema = yup
age: yup.number().required().positive(), // Sweeps
images: yup.array().of(yup.string().required().url()).required(),
// Meta stuff
policies: yup
.object({
fanart: PolicySchema.required(),
fanartOthers: PolicySchema.required(),
kinning: PolicySchema.required(),
shipping: PolicySchema.required(),
fanfiction: PolicySchema.required()
})
.required()
policies: yup.object({
fanart: PolicySchema.required(),
fanartOthers: PolicySchema.required(),
kinning: PolicySchema.required(),
shipping: PolicySchema.required(),
fanfiction: PolicySchema.required()
})
// owners: yup.array().of(yup.string().required()).required().min(1),
// flairs: yup.array().of(yup.mixed()).required().ensure(),
})
@ -157,12 +151,14 @@ export const PartialTrollSchema = yup
yup
.string()
.matches(/^[A-z]+$/, "Letters only")
.length(6)
.min(1)
.max(24)
.lowercase(),
yup
.string()
.matches(/^[A-z]+$/, "Letters only")
.length(6)
.min(1)
.max(24)
.lowercase()
]),
description: yup.string().max(10000),
@ -209,10 +205,10 @@ export const PartialTrollSchema = yup
// Personal
preferences: yup.object({
love: yup.array().of(yup.string().min(5).max(100)).min(3).max(10),
hate: 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(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
trueSign: yup.string().oneOf(TrueSignKeys),
@ -223,21 +219,20 @@ export const PartialTrollSchema = yup
return v === "" ? null : v;
})
.oneOf(TrueSignKeys), // "Keelez Bunbat"
prioritizeTrueSign: yup.boolean(),
class: yup.string().oneOf(ClassKeys),
// Trollian
username: yup
.string()
.matches(
/^(([a-z])[a-z]+)(([A-Z])[a-z]+)$/,
"Username must match Pesterchum formatting."
),
username: yup.string().max(100),
textColor: yup.tuple([
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.
quotes: yup.array().of(yup.string().max(1000)),

View file

@ -1,6 +1,6 @@
import * as yup from "yup";
import { ColorSchema } from "../assist/color";
import { TrueSignKeys } from "../assist/extended_zodiac";
import { PolicySchema } from "../assist/generics";
export const SubmitUserSchema = yup
.object({
@ -13,7 +13,7 @@ export const SubmitUserSchema = yup
.lowercase(),
description: yup.string().max(10000).ensure(),
url: yup.string().notRequired().url(),
trueSign: yup.string().required().oneOf(TrueSignKeys),
trueSign: yup.string().notRequired().oneOf(TrueSignKeys),
pronouns: yup
.array()
.of(
@ -45,9 +45,25 @@ export const SubmitUserSchema = yup
)
.required()
.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(),
bgimage: yup.string().notRequired().url(),
css: yup.string().notRequired(),
code: yup.string().notRequired().max(256, "Too secure!!")
// 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)
]),
policies: yup.object({
fanart: PolicySchema,
fanartOthers: PolicySchema,
kinning: PolicySchema,
shipping: PolicySchema,
fanfiction: PolicySchema
}),
pfp: yup.string().url(),
bgimage: yup.string().url(),
css: yup.string(),
code: yup.string().max(256, "Too secure!!")
// 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),
flairs: yup.array().of(ClientFlairSchema.required()).required(),
quirks: ServerQuirkHolderSchema.required(),
trueSign: TrueSignSchema.required(),
trueSign: TrueSignSchema.notRequired(),
falseSign: TrueSignSchema.notRequired(),
class: ClassSchema.required()
class: ClassSchema.notRequired()
});
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({
flairs: yup.array().of(ClientFlairSchema.required()).required(),
trueSign: TrueSignSchema.required(),
trueSign: TrueSignSchema.notRequired(),
updatedDate: yup.number().notRequired()
});