fix(protocol): enforce message element contracts end to end
Replace the open message bag with a validated discriminated union and preflight complete messages before uploads or sends. Return BAD_REQUEST for invalid or unsendable segments instead of dropping fields, sending partial content, or silently changing private messages.
This commit is contained in:
24 files changed
+1883
-417
No files matched your search
@@ -383,6 +383,19 @@ describe('convertEvent — message elements (13 segment types)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('image: preserves the flash marker on the OneBot segment', async () => {
|
||||
const seg = await segment({
|
||||
type: 'image',
|
||||
fileId: 'fid',
|
||||
imageUrl: 'http://x',
|
||||
flash: true,
|
||||
});
|
||||
expect(seg).toMatchObject({
|
||||
type: 'image',
|
||||
data: { type: 'flash' },
|
||||
});
|
||||
});
|
||||
|
||||
it('at: targetUin -> qq string', async () => {
|
||||
const seg = await segment({ type: 'at', targetUin: PEER_UIN });
|
||||
expect(seg).toEqual({ type: 'at', data: { qq: String(PEER_UIN) } });
|
||||
|
||||
Reference in new issue
Block a user