diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index c252336f99..beaa75e737 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -346,6 +346,18 @@ export class NoteCreateService implements OnApplicationShutdown { data.text = null; } + if (data.cw) { + if (data.cw.length > DB_MAX_NOTE_TEXT_LENGTH) { + data.cw = data.cw.slice(0, DB_MAX_NOTE_TEXT_LENGTH); + } + data.cw = data.cw.trim(); + if (data.cw === '') { + data.cw = null; + } + } else { + data.cw = null; + } + let tags = data.apHashtags; let emojis = data.apEmojis; let mentionedUsers = data.apMentions; diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts index f42d14b466..aecd37aeb9 100644 --- a/packages/backend/src/core/NoteEditService.ts +++ b/packages/backend/src/core/NoteEditService.ts @@ -371,6 +371,18 @@ export class NoteEditService implements OnApplicationShutdown { data.text = null; } + if (data.cw) { + if (data.cw.length > DB_MAX_NOTE_TEXT_LENGTH) { + data.cw = data.cw.slice(0, DB_MAX_NOTE_TEXT_LENGTH); + } + data.cw = data.cw.trim(); + if (data.cw === '') { + data.cw = null; + } + } else { + data.cw = null; + } + let tags = data.apHashtags; let emojis = data.apEmojis; let mentionedUsers = data.apMentions; diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 626f03b758..a4c2e28129 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -252,7 +252,8 @@ export default class extends Endpoint { // 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); } diff --git a/packages/backend/src/server/api/endpoints/notes/edit.ts b/packages/backend/src/server/api/endpoints/notes/edit.ts index 835cbc14fa..b9be145caf 100644 --- a/packages/backend/src/server/api/endpoints/notes/edit.ts +++ b/packages/backend/src/server/api/endpoints/notes/edit.ts @@ -297,9 +297,11 @@ export default class extends Endpoint { // 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({