fix(onebot): keep ambiguous quote previews unresolved
Avoid selecting a text message when another cached message could share its truncated or media preview. Extend the quote-context regression checks. Fixes #502
This commit is contained in:
3 files changed
+44
-8
No files matched your search
@@ -530,7 +530,8 @@ describe('convertEvent — message elements', () => {
|
||||
it('reply: self-sent private targets use the outgoing lookup namespace', async () => {
|
||||
const calls: unknown[][] = [];
|
||||
const seg = await segment(
|
||||
{ type: 'reply', replySeq: 5, replySenderUin: SELF_ID, replyTime: 1234 },
|
||||
{ type: 'reply', replySeq: 5, replySenderUin: SELF_ID, replyTime: 1234,
|
||||
replyElements: [{ type: 'text', text: 'quoted text' }] },
|
||||
{
|
||||
messageIdResolver: (...args) => {
|
||||
calls.push(args);
|
||||
@@ -546,6 +547,7 @@ describe('convertEvent — message elements', () => {
|
||||
5,
|
||||
PRIVATE_SENT_MESSAGE_EVENT,
|
||||
1234,
|
||||
[{ type: 'text', text: 'quoted text' }],
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -947,6 +947,25 @@ describe('MessageStore', () => {
|
||||
expect(store.resolvePrivateReplyMessageId(peerId, 1101, true, sentAt,
|
||||
[{ type: 'text', text: 'same text' }])).toBe(101);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['truncated text', 'short', { type: 'text', data: { text: 'short but longer' } }],
|
||||
['media label', '[语音]', { type: 'record', data: { file: 'voice.amr' } }],
|
||||
])('does not confuse plain text with a competing %s preview', (_name, text, other) => {
|
||||
for (const [id, message] of [[101, [{ type: 'text', data: { text } }]], [102, [other]]] as const) {
|
||||
store.storeMeta(id, {
|
||||
isGroup: false, targetId: peerId, sequence: id, sequenceAuthoritative: true,
|
||||
eventName: PRIVATE_MESSAGE_EVENT, clientSequence: id + 1000,
|
||||
privateDirection: 'outgoing', random: id, timestamp: sentAt,
|
||||
});
|
||||
store.storeEvent(id, false, peerId, id, PRIVATE_MESSAGE_EVENT, {
|
||||
time: sentAt, post_type: 'message_sent', message_type: 'private', sub_type: 'friend',
|
||||
message: JSON.parse(JSON.stringify(message)),
|
||||
});
|
||||
}
|
||||
expect(store.resolvePrivateReplyMessageId(peerId, 999, true, sentAt, [{ type: 'text', text }]))
|
||||
.toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
it('lets a real group event replace an older non-authoritative placeholder', () => {
|
||||
|
||||
Reference in new issue
Block a user