fix(bridge): include the reason code for unavailable private message receipts

Show the reported reason when private message receipts are unavailable. Keep the existing warning when the connection supplies no reason.
This commit is contained in:
DrSmoothl committed 2026-10-31 18:28:05 +08:00
1 parent 299fa85a74
commit fcbb2661d1
2 files changed
+12 -2

No files matched your search

+2 -1
View File
@@ -1378,9 +1378,10 @@ export class QqHookClient extends EventEmitter {
runtimeLog.debug('Client private-message reporting is available: PID=%d', this.pid); runtimeLog.debug('Client private-message reporting is available: PID=%d', this.pid);
} else { } else {
runtimeLog.warn( runtimeLog.warn(
'Client private-message reporting is unavailable: PID=%d status=%d', 'Client private-message reporting is unavailable: PID=%d status=%d%s',
this.pid, this.pid,
frame.status, frame.status,
frame.value0 === 0n ? '' : ` reason=${frame.value0}`,
); );
} }
+10 -1
View File
@@ -218,6 +218,15 @@ describe('QqHookClient client message receipts', () => {
await client.startRecv(onPacket); await client.startRecv(onPacket);
const socket = sockets.mock.results[0]!.value; const socket = sockets.mock.results[0]!.value;
socket.emit('data', pipeFrame({ op: PipeOp.clientMessageState, status: -1 })); socket.emit('data', pipeFrame({ op: PipeOp.clientMessageState, status: -1 }));
socket.emit(
'data',
pipeFrame({ op: PipeOp.clientMessageState, status: -1, value0: 42n }),
);
const warning = 'Client private-message reporting is unavailable: PID=12345 status=-1';
expect(entries.map((entry) => entry.message)).toEqual([
warning,
`${warning} reason=42`,
]);
for (const patch of [ for (const patch of [
{ value0: 0n }, { value0: 0n },
@@ -242,7 +251,7 @@ describe('QqHookClient client message receipts', () => {
entries.filter( entries.filter(
(entry) => entry.scope === 'QQHook.Runtime' && entry.level === 'warn', (entry) => entry.scope === 'QQHook.Runtime' && entry.level === 'warn',
), ),
).toHaveLength(6); ).toHaveLength(7);
socket.emit( socket.emit(
'data', 'data',
pipeFrame({ op: PipeOp.recvPacket, cmd: 'normal', message: '10001', value0: 44n }), pipeFrame({ op: PipeOp.recvPacket, cmd: 'normal', message: '10001', value0: 44n }),