fix(identity): keep live group membership in sync with join and leave
A join now counts the member as in the group right away. A leave drops them from the live roster without forgetting who they are. Other sightings still do not mean the person is in the group.
This commit is contained in:
4 files changed
+132
-2
No files matched your search
@@ -138,6 +138,29 @@ describe('IncomingPacketPipeline roster refresh', () => {
|
||||
expect(fetchGroupMemberList).toHaveBeenCalledWith(GROUP_ID);
|
||||
});
|
||||
|
||||
it('known-group join records the joiner immediately and does not invent the operator', async () => {
|
||||
const { pipeline, identity, fetchGroupList, fetchGroupMemberList } = makePipeline({ plantGroup: true });
|
||||
pipeline.registerCmd('test.roster', () => [join({ userUin: 33333, userUid: 'u_new', operatorUin: 44444, operatorUid: 'u_op' })]);
|
||||
await pipeline.process(pkt());
|
||||
|
||||
expect(identity.findGroupMember(GROUP_ID, 33333)?.uid).toBe('u_new');
|
||||
expect(identity.findGroupMember(GROUP_ID, 33333)?.isRobot).toBeUndefined();
|
||||
expect(identity.findGroupMember(GROUP_ID, 44444)).toBeNull();
|
||||
expect(identity.findUinByUid('u_op')).toBe(44444);
|
||||
expect(fetchGroupList).not.toHaveBeenCalled();
|
||||
expect(fetchGroupMemberList).toHaveBeenCalledWith(GROUP_ID);
|
||||
});
|
||||
|
||||
it('known-group leave drops the member immediately and keeps their identity mapping', async () => {
|
||||
const { pipeline, identity } = makePipeline({ plantGroup: true });
|
||||
identity.rememberGroupMembers(GROUP_ID, [makeMember(22222, 'u_member')]);
|
||||
pipeline.registerCmd('test.roster', () => [leave()]);
|
||||
await pipeline.process(pkt());
|
||||
|
||||
expect(identity.findGroupMember(GROUP_ID, 22222)).toBeNull();
|
||||
expect(identity.findUidByUin(22222, GROUP_ID)).toBe('u_member');
|
||||
});
|
||||
|
||||
it('known-group join / leave / admin fetch only the member list', async () => {
|
||||
for (const event of [join(), leave(), admin()]) {
|
||||
const { pipeline, fetchGroupList, fetchGroupMemberList } = makePipeline({ plantGroup: true });
|
||||
|
||||
Reference in new issue
Block a user