refactor(packages): rename @snowluma/bridge → @snowluma/protocol
The package previously named "bridge" houses the protocol-byte layer (OIDB cmds, msg-push decoders, highway uploaders, element-builder, event bus). The name "bridge" suggested transport/lifecycle, which it isn't — that role lives in core/hook and core/bridge/manager. Rename to match what's actually inside. This is a pure rename: zero logic changes, all 73 import sites updated mechanically and TS-verified. core/onebot dependencies key updated. ESLint override path adjusted for the moved oidb-services directory. Rename detection threshold: git log --find-renames=20% recommended when following history across this commit — content-replacement (@snowluma/bridge → @snowluma/protocol) dropped per-file similarity below git's default 50% on import-heavy files.
This commit is contained in:
238 files changed
+247
-284
No files matched your search
@@ -0,0 +1,53 @@
|
||||
// 0x9067_202 — fetch download-rkey tokens for private/group/fallback
|
||||
// image scopes. The rkey is a server-issued signed download token used
|
||||
// to authenticate every CDN GET against `gchat.qpic.cn` / similar
|
||||
// endpoints.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { NTV2RichMediaReq, NTV2RichMediaResp } from '@snowluma/proto-defs/oidb-actions/media';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
const PRIVATE_IMAGE = 10;
|
||||
const GROUP_IMAGE = 20;
|
||||
const FALLBACK_IMAGE = 2;
|
||||
|
||||
export namespace FetchDownloadRkeys {
|
||||
export const command = 0x9067;
|
||||
export const subCommand = 202;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params {}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, _: Params): NTV2RichMediaReq => ({
|
||||
reqHead: {
|
||||
common: { requestId: 1, command: 202 },
|
||||
scene: { requestType: 2, businessType: 1, sceneType: 0 },
|
||||
client: { agentType: 2 },
|
||||
},
|
||||
downloadRkey: {
|
||||
types: [PRIVATE_IMAGE, GROUP_IMAGE, FALLBACK_IMAGE],
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: NTV2RichMediaResp): NTV2RichMediaResp => {
|
||||
// Propagate server-side OIDB-equivalent error via the embedded
|
||||
// respHead.retCode — bytes-level OIDB errorCode would already
|
||||
// have thrown OidbError before deserialize was called.
|
||||
if (body.respHead?.retCode && body.respHead.retCode !== 0) {
|
||||
throw new Error(body.respHead.message ?? 'fetch download rkey failed');
|
||||
}
|
||||
return body;
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<NTV2RichMediaReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<NTV2RichMediaReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<NTV2RichMediaResp> =>
|
||||
protobuf_decode<OidbBase<NTV2RichMediaResp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps): Promise<NTV2RichMediaResp> =>
|
||||
invokeOidb(deps, FetchDownloadRkeys, {});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// 0xFD4_1 — single-page friend-roster fetch.
|
||||
//
|
||||
// QQ paginates the friend list with a wire-level cursor (`nextUin`).
|
||||
// This namespace handles ONE round-trip — the facade drives the
|
||||
// while-loop until the server stops emitting a next cursor and
|
||||
// concatenates results into the public FriendInfo[] shape.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0xFD4_1Response } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbFriendListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace FetchFriendListPage {
|
||||
export const command = 0xFD4;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params {
|
||||
/** Cursor: `null` for the first page, otherwise the previous
|
||||
* page's `nextUin`. */
|
||||
nextUin: number | null;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbFriendListRequest => {
|
||||
const body: any = {
|
||||
friendCount: 300,
|
||||
field4: 0,
|
||||
field6: 1,
|
||||
field7: 0x7FFFFFFF,
|
||||
body: [
|
||||
{ type: 1, number: { numbers: [103, 102, 20002, 27394] } },
|
||||
{ type: 4, number: { numbers: [100, 101, 102] } },
|
||||
],
|
||||
field10002: [13578, 13579, 13573, 13572, 13568],
|
||||
field10003: 4051,
|
||||
};
|
||||
if (p.nextUin !== null) {
|
||||
body.nextUin = { uin: p.nextUin };
|
||||
}
|
||||
return body;
|
||||
};
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0xFD4_1Response): OidbSvcTrpcTcp0xFD4_1Response => body;
|
||||
|
||||
export const encode = (env: OidbBase<OidbFriendListRequest>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbFriendListRequest>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0xFD4_1Response> =>
|
||||
protobuf_decode<OidbBase<OidbSvcTrpcTcp0xFD4_1Response>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0xFD4_1Response> =>
|
||||
invokeOidb(deps, FetchFriendListPage, params);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
// 0xFE5_2 — fetch the bot's joined-groups list with full per-group
|
||||
// info.
|
||||
//
|
||||
// The verbose `config` blob in the request body asks QQ which
|
||||
// per-group fields to include. Asking for everything blows the
|
||||
// named-pipe write buffer on accounts with ~200+ groups (see #42),
|
||||
// so we keep `config1.*` mostly on but turn off the costly
|
||||
// `field5002`/`field5003` and entire `config2` block that never map
|
||||
// back to a decoded field anyway.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0xFE5_2Response } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace FetchGroupList {
|
||||
export const command = 0xFE5;
|
||||
export const subCommand = 2;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params {}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
const allTrue = true;
|
||||
|
||||
export const serialize = (_ctx: Deps, _: Params): OidbGroupListRequest => ({
|
||||
config: {
|
||||
config1: {
|
||||
groupOwner: allTrue, field2: allTrue, memberMax: allTrue, memberCount: allTrue,
|
||||
groupName: allTrue, field8: allTrue, field9: allTrue, field10: allTrue,
|
||||
field11: allTrue, field12: allTrue, field13: allTrue, field14: allTrue,
|
||||
field15: allTrue, field16: allTrue, field17: allTrue, field18: allTrue,
|
||||
question: allTrue, field20: allTrue, field22: allTrue, field23: allTrue,
|
||||
field24: allTrue, field25: allTrue, field26: allTrue, field27: allTrue,
|
||||
field28: allTrue, field29: allTrue, field30: allTrue, field31: allTrue,
|
||||
field32: allTrue, field5001: allTrue, field5002: false, field5003: false,
|
||||
},
|
||||
config2: {
|
||||
field1: false, field2: false, field3: false, field4: false,
|
||||
field5: false, field6: false, field7: false, field8: false,
|
||||
},
|
||||
config3: { field5: allTrue, field6: allTrue },
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0xFE5_2Response): OidbSvcTrpcTcp0xFE5_2Response => body;
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupListRequest>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupListRequest>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0xFE5_2Response> =>
|
||||
protobuf_decode<OidbBase<OidbSvcTrpcTcp0xFE5_2Response>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps): Promise<OidbSvcTrpcTcp0xFE5_2Response> =>
|
||||
invokeOidb(deps, FetchGroupList, {});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
// 0xFE7_3 — single-page group-member-roster fetch.
|
||||
//
|
||||
// Pagination cursor is the server-issued `token` string. The facade
|
||||
// drives the loop until `token` comes back empty; per-group caching
|
||||
// + inflight coalescing also stays on the facade since both need
|
||||
// state that's per-Bridge (and is what stops Tencent risk-control
|
||||
// from banning the account on busy clients — see #42).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0xFE7_3Response } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupMemberListRequest } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace FetchGroupMemberListPage {
|
||||
export const command = 0xFE7;
|
||||
export const subCommand = 3;
|
||||
|
||||
export interface Params {
|
||||
groupId: number;
|
||||
/** Empty string for the first page; pass the previous response's
|
||||
* `token` to fetch the next page. */
|
||||
token: string;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbGroupMemberListRequest => {
|
||||
const body: any = {
|
||||
groupUin: p.groupId,
|
||||
field2: 5,
|
||||
field3: 2,
|
||||
body: {
|
||||
memberName: true, memberCard: true, level: true, field13: true,
|
||||
field16: true, specialTitle: true, field18: true, field20: true,
|
||||
field21: true, joinTimestamp: true, lastMsgTimestamp: true,
|
||||
shutUpTimestamp: true, field103: true, field104: true, field105: true,
|
||||
field106: true, permission: true, field200: true, field201: true,
|
||||
},
|
||||
};
|
||||
if (p.token) body.token = p.token;
|
||||
return body;
|
||||
};
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0xFE7_3Response): OidbSvcTrpcTcp0xFE7_3Response => body;
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupMemberListRequest>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupMemberListRequest>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0xFE7_3Response> =>
|
||||
protobuf_decode<OidbBase<OidbSvcTrpcTcp0xFE7_3Response>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0xFE7_3Response> =>
|
||||
invokeOidb(deps, FetchGroupMemberListPage, params);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// 0x10C0 — fetch pending group-add requests.
|
||||
// subCommand 1 = main inbox, 2 = filtered (low-priority) inbox
|
||||
//
|
||||
// Returns the wire shape verbatim — the facade does the GroupRequestInfo
|
||||
// mapping because it also needs to thread the `filtered` flag onto
|
||||
// each entry, which the wire doesn't carry.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0x10C0Response } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace FetchGroupRequests {
|
||||
export const command = 0x10C0;
|
||||
|
||||
export interface Params {
|
||||
/** false → subCmd 1 (main inbox), true → subCmd 2 (filtered). */
|
||||
filtered: boolean;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const resolveSubCommand = (p: Params): number => p.filtered ? 2 : 1;
|
||||
|
||||
export const serialize = (_ctx: Deps, _: Params): OidbGroupRequestList => ({
|
||||
count: 20,
|
||||
field2: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbSvcTrpcTcp0x10C0Response): OidbSvcTrpcTcp0x10C0Response => body;
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupRequestList>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupRequestList>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbSvcTrpcTcp0x10C0Response> =>
|
||||
protobuf_decode<OidbBase<OidbSvcTrpcTcp0x10C0Response>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<OidbSvcTrpcTcp0x10C0Response> =>
|
||||
invokeOidb(deps, FetchGroupRequests, params);
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
// 0xFE1_2 (UID form) — fetch a user's profile when only the UID is
|
||||
// known. Same OIDB cmd + subcmd as `FetchUserProfile` (by UIN) but
|
||||
// the request body's field 1 is `uid: string` instead of `uin:
|
||||
// uint32`, and `reserved` stays 0 (no `uinForm`).
|
||||
//
|
||||
// Why two namespaces for the same (cmd, subcmd):
|
||||
// - Group join requests / invitations carry the stranger's UID
|
||||
// only — we never get a UIN for someone who hasn't joined yet.
|
||||
// - The Tencent server WILL reject a UIN-form request with a uid-
|
||||
// shaped value or vice versa, so the two variants must encode
|
||||
// to byte-different wires.
|
||||
// - Matches Lagrange's `OidbSvcTrpcTcp0xFE1_2Uid` vs `…Uin` split
|
||||
// at `dev/Lagrange.Core/.../OidbSvcTrpcTcp0xFE1_2.cs:9-26`
|
||||
// and the dispatch at
|
||||
// `dev/Lagrange.Core/.../FetchUserInfoService.cs:66-78`.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
AvatarInfo,
|
||||
OidbUserInfoByUidRequest,
|
||||
OidbUserInfoResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { UserProfileInfo } from '../../qq-info';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
const REQUESTED_KEYS = [
|
||||
20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026,
|
||||
105, 27372, 27406, 20037,
|
||||
];
|
||||
|
||||
export namespace FetchUserProfileByUid {
|
||||
export const command = 0xFE1;
|
||||
export const subCommand = 2;
|
||||
// No `uinForm` — the UID variant uses the default `reserved=0`
|
||||
// envelope, mirroring Lagrange's untagged constructor at
|
||||
// `OidbSvcTrpcTcp0xFE1_2.cs:9` (isUid=false → Reserved=0).
|
||||
|
||||
export interface Params {
|
||||
uid: string;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbUserInfoByUidRequest => ({
|
||||
uid: p.uid,
|
||||
keys: REQUESTED_KEYS.map(k => ({ key: k })),
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, body: OidbUserInfoResponse): UserProfileInfo => {
|
||||
if (!body.body) throw new Error('user info response body missing');
|
||||
|
||||
const info: UserProfileInfo = {
|
||||
uin: body.body.uin ?? 0,
|
||||
uid: body.body.uid ?? '',
|
||||
nickname: '', remark: '', qid: '', sex: 'unknown', age: 0, sign: '', avatar: '', level: 0,
|
||||
};
|
||||
|
||||
if (body.body.properties) {
|
||||
const bytesMap = new Map<number, Uint8Array>();
|
||||
const numMap = new Map<number, number>();
|
||||
for (const bp of body.body.properties.bytesProperties ?? []) {
|
||||
bytesMap.set(bp.code ?? 0, bp.value ?? new Uint8Array(0));
|
||||
}
|
||||
for (const np of body.body.properties.numberProperties ?? []) {
|
||||
numMap.set(np.number1 ?? 0, np.number2 ?? 0);
|
||||
}
|
||||
const getString = (code: number): string => {
|
||||
const b = bytesMap.get(code);
|
||||
return b ? Buffer.from(b).toString('utf8') : '';
|
||||
};
|
||||
info.nickname = getString(20002);
|
||||
info.remark = getString(103);
|
||||
info.qid = getString(27394);
|
||||
info.sign = getString(102);
|
||||
|
||||
const avatarBytes = bytesMap.get(101);
|
||||
if (avatarBytes) {
|
||||
const av = protobuf_decode<AvatarInfo>(avatarBytes);
|
||||
if (av?.url) info.avatar = av.url + '640';
|
||||
}
|
||||
const sexNum = numMap.get(20009) ?? 0;
|
||||
info.sex = sexNum === 1 ? 'male' : sexNum === 2 ? 'female' : 'unknown';
|
||||
info.age = numMap.get(20037) ?? 0;
|
||||
info.level = numMap.get(105) ?? 0;
|
||||
}
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<OidbUserInfoByUidRequest>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbUserInfoByUidRequest>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbUserInfoResponse> =>
|
||||
protobuf_decode<OidbBase<OidbUserInfoResponse>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<UserProfileInfo> =>
|
||||
invokeOidb(deps, FetchUserProfileByUid, params);
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
// 0xFE1_2 — fetch a user's profile (nickname / qid / sex / age / sign
|
||||
// / avatar / QQ level).
|
||||
//
|
||||
// `uinForm` is set so the server takes the UIN-form validation path;
|
||||
// without it newer NTQQ versions reject the request with
|
||||
// `[oidb] one of uid/openid is invaild`. Matches Lagrange.Core's
|
||||
// FetchStrangerByUin (Reserved = 1).
|
||||
//
|
||||
// Property key catalogue (cross-checked against LagrangeV2's
|
||||
// FetchStrangerService.cs):
|
||||
// 101 — avatar info (proto-encoded AvatarInfo)
|
||||
// 102 — sign (signature)
|
||||
// 103 — remark
|
||||
// 105 — QQ level (numeric)
|
||||
// 20002 — nickname
|
||||
// 20009 — gender (1 male / 2 female / 255 unknown)
|
||||
// 20037 — age
|
||||
// 27394 — QID
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
AvatarInfo,
|
||||
OidbUserInfoRequest,
|
||||
OidbUserInfoResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { UserProfileInfo } from '../../qq-info';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
const REQUESTED_KEYS = [
|
||||
20002, 27394, 20009, 20031, 101, 103, 102, 20020, 20003, 20026,
|
||||
105, 27372, 27406, 20037,
|
||||
];
|
||||
|
||||
export namespace FetchUserProfile {
|
||||
export const command = 0xFE1;
|
||||
export const subCommand = 2;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params {
|
||||
uin: number;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (_ctx: Deps, p: Params): OidbUserInfoRequest => ({
|
||||
uin: p.uin,
|
||||
keys: REQUESTED_KEYS.map(k => ({ key: k })),
|
||||
});
|
||||
|
||||
/** Defaults the response uin to `requestedUin` because the server
|
||||
* sometimes elides its echo. `invoke` below binds `params.uin` via
|
||||
* the spec override so the namespace's call surface still takes
|
||||
* only `(ctx, body)`. */
|
||||
export const deserializeWithFallback = (
|
||||
body: OidbUserInfoResponse, requestedUin: number,
|
||||
): UserProfileInfo => {
|
||||
if (!body.body) throw new Error('user info response body missing');
|
||||
|
||||
const info: UserProfileInfo = {
|
||||
uin: body.body.uin ?? requestedUin,
|
||||
uid: body.body.uid ?? '',
|
||||
nickname: '', remark: '', qid: '', sex: 'unknown', age: 0, sign: '', avatar: '', level: 0,
|
||||
};
|
||||
|
||||
if (body.body.properties) {
|
||||
const bytesMap = new Map<number, Uint8Array>();
|
||||
const numMap = new Map<number, number>();
|
||||
for (const bp of body.body.properties.bytesProperties ?? []) {
|
||||
bytesMap.set(bp.code ?? 0, bp.value ?? new Uint8Array(0));
|
||||
}
|
||||
for (const np of body.body.properties.numberProperties ?? []) {
|
||||
numMap.set(np.number1 ?? 0, np.number2 ?? 0);
|
||||
}
|
||||
const getString = (code: number): string => {
|
||||
const b = bytesMap.get(code);
|
||||
return b ? Buffer.from(b).toString('utf8') : '';
|
||||
};
|
||||
info.nickname = getString(20002);
|
||||
info.remark = getString(103);
|
||||
info.qid = getString(27394);
|
||||
info.sign = getString(102);
|
||||
|
||||
const avatarBytes = bytesMap.get(101);
|
||||
if (avatarBytes) {
|
||||
const av = protobuf_decode<AvatarInfo>(avatarBytes);
|
||||
if (av?.url) info.avatar = av.url + '640';
|
||||
}
|
||||
const sexNum = numMap.get(20009) ?? 0;
|
||||
info.sex = sexNum === 1 ? 'male' : sexNum === 2 ? 'female' : 'unknown';
|
||||
info.age = numMap.get(20037) ?? 0;
|
||||
info.level = numMap.get(105) ?? 0;
|
||||
}
|
||||
|
||||
return info;
|
||||
};
|
||||
|
||||
// Default deserialize uses uin=0 fallback — invoke() rewires it to
|
||||
// the requested uin via the per-call spec override below. Tests
|
||||
// that call deserialize directly should use deserializeWithFallback.
|
||||
export const deserialize = (_ctx: Deps, body: OidbUserInfoResponse): UserProfileInfo =>
|
||||
deserializeWithFallback(body, 0);
|
||||
|
||||
export const encode = (env: OidbBase<OidbUserInfoRequest>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbUserInfoRequest>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbUserInfoResponse> =>
|
||||
protobuf_decode<OidbBase<OidbUserInfoResponse>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<UserProfileInfo> =>
|
||||
invokeOidb(deps, {
|
||||
...FetchUserProfile,
|
||||
deserialize: (_ctx, body) => deserializeWithFallback(body, params.uin),
|
||||
}, params);
|
||||
}
|
||||
Reference in new issue
Block a user