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:
7 files changed
+280
-37
No files matched your search
@@ -0,0 +1,44 @@
|
||||
// Faceroam.OpReq opType=1 — 拉取当前账号的收藏表情 id 列表。
|
||||
//
|
||||
// 和 delete 同一个 trpc service,区别在 field3=1、inner 带 qqVersion、
|
||||
// 并置 field6=1。响应 item.faceIds 是完整列表;截条数由调用方做。
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { FaceroamOpReq, FaceroamOpResp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { OidbSender } from '../../oidb-service';
|
||||
import { FACEROAM_SERVICE, makeInner } from './shared';
|
||||
|
||||
export namespace FetchCustomFaceList {
|
||||
export interface Params {
|
||||
/** 当前账号 UIN,写入 field2。 */
|
||||
uin: string;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): FaceroamOpReq => ({
|
||||
inner: makeInner(true),
|
||||
uin: BigInt(p.uin),
|
||||
field3: 1,
|
||||
field6: 1,
|
||||
});
|
||||
|
||||
export const encode = (req: FaceroamOpReq): Uint8Array =>
|
||||
protobuf_encode<FaceroamOpReq>(req);
|
||||
|
||||
export const decode = (bytes: Uint8Array): FaceroamOpResp =>
|
||||
protobuf_decode<FaceroamOpResp>(bytes);
|
||||
|
||||
export async function invoke(deps: Deps, params: Params): Promise<string[]> {
|
||||
const body = encode(serialize(deps, params));
|
||||
const result = await deps.sendRawPacket(FACEROAM_SERVICE, body);
|
||||
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||
throw new Error(result.errorMessage || 'fetch custom face failed');
|
||||
}
|
||||
const resp = decode(result.responseData);
|
||||
if (!resp || (resp.retCode ?? 0) !== 0) {
|
||||
throw new Error(`fetch custom face error: ${resp?.message || 'unknown'}`);
|
||||
}
|
||||
return resp.item?.faceIds || [];
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ export const FACEROAM_SERVICE = 'Faceroam.OpReq';
|
||||
// 真出问题再从 identity 里取。
|
||||
/** osVersion 字符串,Faceroam inner 与 0x902e 业务体 f2 共用。 */
|
||||
export const CLIENT_VERSION = '10.0.26200';
|
||||
const CLIENT_BUILD = '9.9.26-44343';
|
||||
/** qqVersion on the Faceroam list inner. Keep the value list already sends. Delete omits this field. */
|
||||
const LIST_QQ_VERSION = '9.9.28-46928';
|
||||
|
||||
/**
|
||||
* 构造请求 inner(field1 客户端环境)。fetch 带 qqVersion,delete 不带——
|
||||
@@ -23,6 +24,6 @@ const CLIENT_BUILD = '9.9.26-44343';
|
||||
*/
|
||||
export function makeInner(withQqVersion: boolean): FaceroamOpReqInner {
|
||||
const inner: FaceroamOpReqInner = { field1: 1, osVersion: CLIENT_VERSION };
|
||||
if (withQqVersion) inner.qqVersion = CLIENT_BUILD;
|
||||
if (withQqVersion) inner.qqVersion = LIST_QQ_VERSION;
|
||||
return inner;
|
||||
}
|
||||
Reference in new issue
Block a user