Make profile bio max length configurable
This commit is contained in:
parent
9d2f97a92a
commit
20b2843680
@ -19,6 +19,8 @@
|
||||
import { route } from "@spacebar/api";
|
||||
import {
|
||||
Badge,
|
||||
Config,
|
||||
FieldErrors,
|
||||
Member,
|
||||
PrivateUserProjection,
|
||||
User,
|
||||
@ -136,6 +138,18 @@ router.patch(
|
||||
select: [...PrivateUserProjection, "data"],
|
||||
});
|
||||
|
||||
if (body.bio) {
|
||||
const { maxBio } = Config.get().limits.user;
|
||||
if (body.bio.length > maxBio) {
|
||||
throw FieldErrors({
|
||||
bio: {
|
||||
code: "BIO_INVALID",
|
||||
message: `Bio must be less than ${maxBio} in length`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
user.assign(body);
|
||||
await user.save();
|
||||
|
||||
|
@ -189,6 +189,18 @@ router.patch(
|
||||
}
|
||||
}
|
||||
|
||||
if (body.bio) {
|
||||
const { maxBio } = Config.get().limits.user;
|
||||
if (body.bio.length > maxBio) {
|
||||
throw FieldErrors({
|
||||
bio: {
|
||||
code: "BIO_INVALID",
|
||||
message: `Bio must be less than ${maxBio} in length`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
user.assign(body);
|
||||
user.validate();
|
||||
await user.save();
|
||||
|
@ -20,4 +20,5 @@ export class UserLimits {
|
||||
maxGuilds: number = 1048576;
|
||||
maxUsername: number = 32;
|
||||
maxFriends: number = 5000;
|
||||
maxBio: number = 190;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ export class User extends BaseClass {
|
||||
bot: boolean = false; // if user is bot
|
||||
|
||||
@Column()
|
||||
bio: string = ""; // short description of the user (max 190 chars -> should be configurable)
|
||||
bio: string = ""; // short description of the user
|
||||
|
||||
@Column()
|
||||
system: boolean = false; // shouldn't be used, the api sends this field type true, if the generated message comes from a system generated author
|
||||
|
@ -23,9 +23,6 @@ export interface UserModifySchema {
|
||||
*/
|
||||
username?: string;
|
||||
avatar?: string | null;
|
||||
/**
|
||||
* @maxLength 1024
|
||||
*/
|
||||
bio?: string;
|
||||
accent_color?: number;
|
||||
banner?: string | null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user