From 94b1c99c86197807e2bc50bfa7642a0d60b86f01 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 25 Dec 2022 14:28:51 +0900 Subject: [PATCH] fix(server): trim long text of note from ap Fix #9407 --- CHANGELOG.md | 1 + packages/backend/src/core/NoteCreateService.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d58ff7691..64b47883d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,7 @@ You should also include the user name that made the change. - Server: 引用内の文章がnyaizeされてしまう問題を修正 @kabo2468 - Server: Bug fix for Pinned Users lookup on instance @squidicuzz - Server: Fix peers API returning suspended instances @ineffyble +- Server: trim long text of note from ap @syuilo - Client: case insensitive emoji search @saschanaz - Client: InAppウィンドウが操作できなくなることがあるのを修正 @tamaina - Client: use proxied image for instance icon @syuilo diff --git a/packages/backend/src/core/NoteCreateService.ts b/packages/backend/src/core/NoteCreateService.ts index e9c225231..cc6c21344 100644 --- a/packages/backend/src/core/NoteCreateService.ts +++ b/packages/backend/src/core/NoteCreateService.ts @@ -41,6 +41,7 @@ import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerServ import { NoteReadService } from '@/core/NoteReadService.js'; import { RemoteUserResolveService } from '@/core/RemoteUserResolveService.js'; import { bindThis } from '@/decorators.js'; +import { DB_MAX_NOTE_TEXT_LENGTH } from '@/const.js'; const mutedWordsCache = new Cache<{ userId: UserProfile['userId']; mutedWords: UserProfile['mutedWords']; }[]>(1000 * 60 * 5); @@ -259,6 +260,9 @@ export class NoteCreateService { } if (data.text) { + if (data.text.length > DB_MAX_NOTE_TEXT_LENGTH) { + data.text = data.text.slice(0, DB_MAX_NOTE_TEXT_LENGTH); + } data.text = data.text.trim(); } else { data.text = null;