refactor(protocol): keep custom-face list encoding with delete

Profile still turns ids into image URLs and slices the count. Asking
for ids no longer round-trips through those URLs.
This commit is contained in:
DrSmoothl committed 2026-08-29 23:58:56 +08:00
1 parent 9cdbcb0299
commit 117335166f
7 files changed
+280 -37

No files matched your search

@@ -61,6 +61,7 @@ const APIS_ROUTING: Record<string, [string, string]> = {
setAvatar: ['profile', 'setAvatar'],
setGroupAvatar: ['profile', 'setGroupAvatar'],
fetchCustomFace: ['profile', 'fetchCustomFace'],
fetchCustomFaceIds: ['profile', 'fetchCustomFaceIds'],
fetchCustomFaceDetails: ['profile', 'fetchCustomFaceDetails'],
getProfileLike: ['profile', 'getLike'],
getUnidirectionalFriendList: ['profile', 'getUnidirectionalFriendList'],
@@ -1486,6 +1487,45 @@ describe('extended-actions / set_group_portrait', () => {
});
});
describe('extended-actions / fetch_custom_face', () => {
it('return_type=id uses the id list directly', async () => {
const fetchCustomFaceIds = vi.fn(async () => [
'10001_0_0_0_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_0_0',
'10001_0_0_0_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB_0_0',
]);
const fetchCustomFace = vi.fn();
const bridge = fakeBridge({ fetchCustomFaceIds, fetchCustomFace });
const response = await makeHandler(fakeCtx(bridge)).handle('fetch_custom_face', {
count: '2',
return_type: 'id',
});
expect(fetchCustomFaceIds).toHaveBeenCalledWith(2);
expect(fetchCustomFace).not.toHaveBeenCalled();
expect(response).toMatchObject({
status: 'ok',
data: [
'10001_0_0_0_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_0_0',
'10001_0_0_0_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB_0_0',
],
});
});
it('default return_type uses image urls', async () => {
const url = 'https://p.qpic.cn/qq_expression/10001/id/0';
const fetchCustomFace = vi.fn(async () => [url]);
const fetchCustomFaceIds = vi.fn();
const bridge = fakeBridge({ fetchCustomFace, fetchCustomFaceIds });
const response = await makeHandler(fakeCtx(bridge)).handle('fetch_custom_face', { count: '1' });
expect(fetchCustomFace).toHaveBeenCalledWith(1);
expect(fetchCustomFaceIds).not.toHaveBeenCalled();
expect(response).toMatchObject({ status: 'ok', data: [url] });
});
});
describe('extended-actions / fetch_custom_face_detail', () => {
it('returns real packet-backed fields with SnowLuma and NapCat resource aliases', async () => {
const fetchCustomFaceDetails = vi.fn(async () => [{