fix length validation
This commit is contained in:
parent
063b2ff266
commit
3842a1ee8c
4 changed files with 29 additions and 2 deletions
|
|
@ -252,7 +252,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private noteCreateService: NoteCreateService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.text && (ps.text.length > this.config.maxNoteLength)) {
|
||||
const contentLength = (ps.text?.length ?? 0) + (ps.cw?.length ?? 0);
|
||||
if (contentLength > this.config.maxNoteLength) {
|
||||
throw new ApiError(meta.errors.maxLength);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -297,9 +297,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private noteEditService: NoteEditService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.text && (ps.text.length > this.config.maxNoteLength)) {
|
||||
const contentLength = (ps.text?.length ?? 0) + (ps.cw?.length ?? 0);
|
||||
if (contentLength > this.config.maxNoteLength) {
|
||||
throw new ApiError(meta.errors.maxLength);
|
||||
}
|
||||
|
||||
let visibleUsers: MiUser[] = [];
|
||||
if (ps.visibleUserIds) {
|
||||
visibleUsers = await this.usersRepository.findBy({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue