Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(group-chat): 校验解散与回应者查询的房间类型
Dash502b51bfdb38
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.tsindex 96348e1723..ae02296f05 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServer.test.ts@@ -1940,6 +1940,7 @@ describe('Chat Server result delivery and refresh', () => {const roomOf = (id: string) => ({ ...room(id), kind: id in kinds ? kinds[id] : 'group' });beforeEach(() => {fixture.handle.mockImplementation((route, method) => {+ if (route === '/me') return { body: { actor: { id: selfId }, capabilities: { groupLifecycleVersion: 1 } } };if (route === '/conversations?limit=100') return { body: [roomOf(directId), roomOf(roomId), roomOf(channelId), roomOf(futureId)] };if (route.endsWith('/snapshot')) return { body: { room: roomOf(route.split('/')[2]), cursor: '1', messages: [],members: [{ id: selfId, kind: 'human', ownerActorId: selfId, state: 'joined', role: 'owner' }] } };@@ -1960,6 +1961,23 @@ describe('Chat Server result delivery and refresh', () => {expect(await service.getGroup(other)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });});+ it.each([directId, channelId, futureId])('rejects dissolution and reactor reads for %s without subscriptions or other room access', async groupId => {+ await service.listGroups();+ await vi.advanceTimersByTimeAsync(2000);+ const socket = fixture.sockets[0];+ Object.defineProperty(socket, 'readyState', { value: 1 });+ socket.emit('message', JSON.stringify({ type: 'ready' }));+ await vi.advanceTimersByTimeAsync(0);+ vi.mocked(socket.send).mockClear();+ fixture.handle.mockClear();+ expect(await service.chatServer!.manage({ groupId, action: { type: 'dissolve', expectedRevision: 1 } }))+ .toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });+ expect(await service.chatServer!.reactors({ groupId, messageId: roomId, emoji: '👍' }))+ .toMatchObject({ ok: false, errorCode: 'CONVERSATION_NOT_FOUND' });+ expect(fixture.handle.mock.calls.filter(([route]) => String(route).startsWith(`/conversations/${groupId}`) && !String(route).endsWith('/snapshot'))).toEqual([]);+ expect(vi.mocked(socket.send).mock.calls.filter(([raw]) => String(raw).includes(groupId))).toEqual([]);+ });+it('does not archive, leave, rename, re-member, post into or invite to a direct room through group actions', async () => {expect(await service.deleteGroup(directId)).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });expect(await service.updateGroup({ groupId: directId, name: 'Renamed' })).toMatchObject({ ok: false, errorCode: 'NOT_FOUND' });diff --git a/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.tsindex fc0869dddc..0f271fd4f9 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/chatServerMembership.test.ts@@ -203,7 +203,7 @@ describe('Chat Server membership notices', () => {expect(fixture.handle).toHaveBeenCalledWith(`/conversations/${roomId}/dissolve`, 'POST', expect.objectContaining({ expectedRevision: 1, operationId: expect.any(String) }));expect(fixture.handle.mock.calls.some(([, method]) => method === 'PATCH')).toBe(false);});- it.each([{ kind: 'direct', code: 'GROUP_REQUIRED' }, { role: 'admin', code: 'OWNER_REQUIRED' }, { role: 'member', code: 'OWNER_REQUIRED' }])('refuses invalid dissolution %j', async ({ code, ...options }) => {+ it.each([{ kind: 'direct', code: 'CONVERSATION_NOT_FOUND' }, { role: 'admin', code: 'OWNER_REQUIRED' }, { role: 'member', code: 'OWNER_REQUIRED' }])('refuses invalid dissolution %j', async ({ code, ...options }) => {lifecycle(options);expect(await service.chatServer!.manage({ groupId: roomId, action: { type: 'dissolve', expectedRevision: 1 } })).toMatchObject({ ok: false, errorCode: code });expect(fixture.handle.mock.calls.some(([route]) => route.endsWith('/dissolve'))).toBe(false);diff --git a/apps/desktop/src/main/maker-ipc/chatServer.ts b/apps/desktop/src/main/maker-ipc/chatServer.tsindex bdfe324616..627fc6b1da 100644--- a/apps/desktop/src/main/maker-ipc/chatServer.ts+++ b/apps/desktop/src/main/maker-ipc/chatServer.ts@@ -1505,8 +1505,7 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD}if (action.type === 'dissolve') {if (!supportsDissolve) throw new Error('LIFECYCLE_UNAVAILABLE');- const s = await snapshot(target);- if (s.room.kind !== 'group') throw new Error('GROUP_REQUIRED');+ const s = await groupSnapshot(target);const owner = s.members.find(m => m.state === 'joined' && m.role === 'owner' && (m.id === selfId || m.ownerActorId === selfId));if (!owner) throw new Error('OWNER_REQUIRED');z.object({ revision: z.number().int().positive(), dissolvedAt: z.string().refine(value => Number.isFinite(Date.parse(value))), dissolvedBy: id })@@ -1581,6 +1580,9 @@ function createChatServer(local: BotGroupChatService, deps: BotGroupChatServiceD}),reactors: input => result(async () => {const i = z.object({ groupId: id, messageId: id, emoji: z.string().min(1).max(128) }).strict().parse(input);+ // Keep this read-only entry free of actor registration and subscriptions while applying the same room allowlist.+ const s = await api<Snapshot>(`/conversations/${i.groupId}/snapshot`);+ if (!isGroupRoom(s.room)) throw new Error('NOT_A_GROUP');// Read-only: reuse the registered actor, or read it without the actor/profile sync in register().const self = selfId || (await api<{ actor: { id: string } }>('/me')).actor.id;// Every member state is listed, so actors who have since left keep their group name.