fix(onebot): reject ambiguous video message combinations
Prevent ordinary messages and forwarded nodes from combining video content with visible sibling segments or additional videos. Invalid combinations now fail before parsing side effects, media work, or bridge sends, while exact empty text placeholders remain compatible with a single video. Cover group, private, temporary-session, CQ string, nested forward, cached forward, and protocol-builder paths. Preserve the existing standalone window-shake behavior and keep valid single-video messages unchanged.
This commit is contained in:
8 files changed
+371
-29
No files matched your search
@@ -10,6 +10,7 @@ import type { BridgeContext } from './bridge-context';
|
||||
import { sysFaceStore } from './sys-face-store';
|
||||
import type { MessageElement } from './events';
|
||||
import {
|
||||
assertVideoSendPolicy,
|
||||
assertWindowShakeSendPolicy,
|
||||
assertValidMessageElements,
|
||||
MessageElementValidationError,
|
||||
@@ -458,6 +459,13 @@ export async function buildSendElems(elements: MessageElement[], ctx?: SendConte
|
||||
// preserves all-or-nothing semantics: a malformed later segment cannot make
|
||||
// an earlier media segment perform side effects before the send is rejected.
|
||||
assertValidMessageElements(elements, 'W');
|
||||
// Canonical MessageElements cannot contain empty text. OneBot's explicit
|
||||
// empty-text compatibility placeholders are removed before this boundary,
|
||||
// so the array length here is the effective on-wire segment count.
|
||||
assertVideoSendPolicy(
|
||||
elements.filter((element) => element.type === 'video').length,
|
||||
elements.length,
|
||||
);
|
||||
assertWindowShakeSendPolicy(
|
||||
elements.filter((element) => element.type === 'poke').length,
|
||||
elements.length,
|
||||
|
||||
Reference in new issue
Block a user