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

@@ -68,6 +68,35 @@ function makeProfile(uin: number, uid: string, nickname: string): UserProfileInf
}
describe('Bridge roster warmup', () => {
it('settles all callers, including callers waiting before the first connection', async () => {
const bridge = new Bridge(IdentityService.memory('10001'));
const fetchFriends = vi
.spyOn(bridge.apis.contacts, 'fetchFriendList')
.mockResolvedValue([makeFriend(10001, 'u_self', 'me')]);
vi.spyOn(bridge.apis.contacts, 'fetchGroupList').mockResolvedValue([]);
const beforeLogin = bridge.whenRosterWarmupSettled();
bridge.bindPid(7, sender);
const afterLogin = bridge.whenRosterWarmupSettled();
const expected = { friendsLoaded: true, groupsLoaded: true };
await expect(Promise.all([beforeLogin, afterLogin])).resolves.toEqual([expected, expected]);
await expect(bridge.whenRosterWarmupSettled()).resolves.toEqual(expected);
expect(fetchFriends).toHaveBeenCalledOnce();
await bridge.dispose();
await expect(bridge.whenRosterWarmupSettled()).resolves.toEqual(expected);
});
it('releases warmup waiters when disposed before the first connection', async () => {
const bridge = new Bridge(IdentityService.memory('10001'));
const waiting = bridge.whenRosterWarmupSettled();
await bridge.dispose();
await expect(waiting).resolves.toEqual({ friendsLoaded: false, groupsLoaded: false });
await expect(bridge.whenRosterWarmupSettled()).resolves.toEqual({
friendsLoaded: false,
groupsLoaded: false,
});
});
it('fetches friends and groups after the first sender and writes Identity', async () => {
const identity = IdentityService.memory('10001');
const bridge = new Bridge(identity);