CWを使用する場合、注釈を空にすることを許可しない

Resolve #12217
This commit is contained in:
syuilo 2023-11-03 08:17:35 +09:00
parent 7f5ad5badb
commit 82526ad4f3
5 changed files with 13 additions and 2 deletions

View file

@ -16,8 +16,8 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
import { NoteCreateService } from '@/core/NoteCreateService.js';
import { DI } from '@/di-symbols.js';
import { ApiError } from '../../error.js';
import { isPureRenote } from '@/misc/is-pure-renote.js';
import { ApiError } from '../../error.js';
export const meta = {
tags: ['notes'],
@ -109,7 +109,7 @@ export const paramDef = {
visibleUserIds: { type: 'array', uniqueItems: true, items: {
type: 'string', format: 'misskey:id',
} },
cw: { type: 'string', nullable: true, maxLength: 100 },
cw: { type: 'string', nullable: true, minLength: 1, maxLength: 100 },
localOnly: { type: 'boolean', default: false },
reactionAcceptance: { type: 'string', nullable: true, enum: [null, 'likeOnly', 'likeOnlyForRemote', 'nonSensitiveOnly', 'nonSensitiveOnlyForLocalLikeOnlyForRemote'], default: null },
noExtractMentions: { type: 'boolean', default: false },

View file

@ -658,6 +658,14 @@ function deleteDraft() {
}
async function post(ev?: MouseEvent) {
if (useCw && (cw == null || cw.trim() === '')) {
os.alert({
type: 'error',
text: i18n.ts.cwNotationRequired,
});
return;
}
if (ev) {
const el = ev.currentTarget ?? ev.target;
const rect = el.getBoundingClientRect();