feat(core): add process facts to ordered account notifications (#539)

* feat(core): carry hook process status in notifications

`offline` alone cannot tell an external supervisor whether the QQ session dropped (log back in) or the process is gone (restart the client). Resolve the hook process behind a UIN at notify time and expose `status`, `pid` and `error` as template variables; a failing lookup degrades to empty values so delivery is never blocked.

The default webhook/email templates gain a process-status line; existing channels keep their stored template untouched.

* fix(core): preserve notification lifecycle ordering and simplify state

---------

Co-authored-by: zhngzhu <[email protected]>
Co-authored-by: 手瓜一十雪 <[email protected]>
This commit is contained in:
authored and GitHub committed 2026-10-18 11:13:58 +08:00
1 parent b6d86a586d
commit 8e24995fc3
19 files changed
+616 -387

No files matched your search

@@ -339,6 +339,7 @@ describe('BridgeManager PID ownership', () => {
manager.onPidDisconnected(101);
expect(manager.getSession('10001')).toBeNull();
expect(closed).toHaveBeenCalledOnce();
expect(closed).toHaveBeenCalledWith('10001', bridge, 101);
await expect(
bridge.sendRawPacket('Test.NoSender', new Uint8Array([3])),
).resolves.toMatchObject({
@@ -512,7 +513,7 @@ describe('BridgeManager PID ownership', () => {
expect(started).toHaveBeenCalledTimes(2);
expect(closed).toHaveBeenCalledOnce();
expect(closed).toHaveBeenCalledWith('10001', expect.anything());
expect(closed).toHaveBeenCalledWith('10001', expect.anything(), 101);
expect(manager.getSession('10001')).toBeNull();
expect(manager.getSession('20002')!.bridge).toBe(targetBridge);
expect(targetBridge.activePid).toBe(101);
@@ -561,9 +562,7 @@ describe('BridgeManager PID ownership', () => {
try {
manager.onHookLogin(101, '10001', sender.client);
// Deliberately violate the private ownership invariant through Bridge's
// compatibility surface: Manager still maps PID 101 to this UIN, while
// Bridge no longer owns either the PID or its sender.
// Remove the connection without updating the manager's ownership index.
manager.getSession('10001')!.bridge.detachPid(101);
expect(() => manager.onPacket(packet(101, '10001'))).toThrowError(