feat(onebot): expose public contact profiles

Refs #615
This commit is contained in:
DrSmoothl committed 2026-11-02 08:06:27 +08:00
1 parent 2b63f375fc
commit 45c3a6841a
34 files changed
+2427 -211

No files matched your search

+18 -1
View File
@@ -1,9 +1,26 @@
import { describe, expect, it } from 'vitest';
import { describe, expect, it, vi } from 'vitest';
import type { ApiActionContext } from '../src/api-handler';
import { actions } from '../src/actions/friend';
const getStrangerInfo = actions.find((action) => action.names[0] === 'get_stranger_info');
describe('get_friend_list profile option', () => {
it('defaults off, validates the option and forwards explicit enrichment', async () => {
const action = actions.find((entry) => entry.names[0] === 'get_friend_list')!;
const getFriendList = vi.fn(async () => []);
const handler = action.toHandler({ getFriendList } as unknown as ApiActionContext);
await handler({});
expect(getFriendList).toHaveBeenLastCalledWith(false);
await handler({ with_profile: true });
expect(getFriendList).toHaveBeenLastCalledWith(true);
expect(await handler({ with_profile: 'invalid' })).toMatchObject({ status: 'failed' });
expect(getFriendList).toHaveBeenCalledTimes(2);
expect(
await action.toHandler({} as ApiActionContext)({ with_profile: true }),
).toMatchObject({ status: 'failed', wording: 'friend profile provider unavailable' });
});
});
if (!getStrangerInfo) {
throw new Error('get_stranger_info action missing');
}