diff options
| author | Julia <julia@insertdomain.name> | 2024-10-29 03:04:25 +0000 |
|---|---|---|
| committer | Julia <julia@insertdomain.name> | 2024-10-29 03:04:25 +0000 |
| commit | 1520bc1715cd974faa9c20ae5caeceb16a4c0b8e (patch) | |
| tree | a72cd1371e1c662026b92fa8e631859afed8dbbb /packages/backend/src/server/api/endpoints/notes/create.ts | |
| parent | merge: Collapse user activity, files, and listenbrainz on mobile (resolves #7... (diff) | |
| parent | fix poll option limit in masto API (diff) | |
| download | sharkey-1520bc1715cd974faa9c20ae5caeceb16a4c0b8e.tar.gz sharkey-1520bc1715cd974faa9c20ae5caeceb16a4c0b8e.tar.bz2 sharkey-1520bc1715cd974faa9c20ae5caeceb16a4c0b8e.zip | |
merge: Split character limits between local and remote notes (resolves #723) (!669)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/669
Closes #723
Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Julia <julia@insertdomain.name>
Diffstat (limited to 'packages/backend/src/server/api/endpoints/notes/create.ts')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/notes/create.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 412491afaa..d1cf0123dc 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -90,6 +90,12 @@ export const meta = { id: '3ac74a84-8fd5-4bb0-870f-01804f82ce16', }, + maxCwLength: { + message: 'You tried posting a content warning which is too long.', + code: 'MAX_CW_LENGTH', + id: '7004c478-bda3-4b4f-acb2-4316398c9d52', + }, + cannotReplyToSpecifiedVisibilityNoteWithExtendedVisibility: { message: 'You cannot reply to a specified visibility note with extended visibility.', code: 'CANNOT_REPLY_TO_SPECIFIED_VISIBILITY_NOTE_WITH_EXTENDED_VISIBILITY', @@ -147,7 +153,7 @@ export const paramDef = { visibleUserIds: { type: 'array', uniqueItems: true, items: { type: 'string', format: 'misskey:id', } }, - cw: { type: 'string', nullable: true, minLength: 1, maxLength: 500 }, + cw: { type: 'string', nullable: true, minLength: 1 }, localOnly: { type: 'boolean', default: false }, reactionAcceptance: { type: 'string', nullable: true, enum: [null, 'likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote'], default: null }, noExtractMentions: { type: 'boolean', default: false }, @@ -250,10 +256,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- private noteCreateService: NoteCreateService, ) { super(meta, paramDef, async (ps, me) => { - const contentLength = (ps.text?.length ?? 0) + (ps.cw?.length ?? 0); - if (contentLength > this.config.maxNoteLength) { + if (ps.text && ps.text.length > this.config.maxNoteLength) { throw new ApiError(meta.errors.maxLength); } + if (ps.cw && ps.cw.length > this.config.maxCwLength) { + throw new ApiError(meta.errors.maxCwLength); + } let visibleUsers: MiUser[] = []; if (ps.visibleUserIds) { |