feat(proton): finish OIDB migration — runOidb on protobuf_encode<OidbBase<T>>
Closes the OIDB phase of the proton migration. Every consumer that
talked to the OIDB service through the old runtime
`makeOidbBaseSchema()` factory now goes through the compile-time
generic `OidbBase<T>` instead — proton monomorphizes the codec per
call-site instantiation.
@snowluma/proton — two analyzer fixes uncovered by the migration:
1. Skip queuing call-site type-args that reference an *enclosing
generic function's* type parameter for monomorphization. Before
this, a wrapper like
export function encodeOidbEnv<T>(env: OidbBase<T>): Uint8Array {
return protobuf_encode<OidbBase<T>>(env);
}
would cause the analyzer to mint a literal `OidbBase__T` registry
entry with `body.typeName = 'T'`, which the post-walk wire-type
guard then tripped on. The enclosing-scope type params are tracked
on a stack as the walker descends into FunctionDeclaration,
FunctionExpression, ArrowFunction, MethodDeclaration nodes; matching
call sites are skipped (the wrapper-binding path is still
responsible for materialising concrete codecs at downstream call
sites).
2. Register *explicitly* empty interfaces (`interface X {}`) as
zero-field proto messages. OIDB has a handful of these
('this call has no meaningful response body' placeholders —
Oidb0xeb7Resp, Oidb0xcd4Resp, Oidb0x112aResp, Oidb0x8a0Resp,
Oidb0xf16Resp, OidbClientKeyReq). Proto3 wire allows zero-field
messages, and downstream code does `protobuf_decode<OidbBase<X>>`
where X is one of these — the wire-type guard would otherwise trip
on the missing `X` registration. Interfaces that have members but
no pb-marked fields are still NOT registered.
@snowluma/core — the OIDB-layer refactor itself:
bridge-oidb.ts ditches the runtime ProtoSchema factory and exposes:
- makeOidbEnvelope<T>(oidbCmd, subCmd, body, isUid) pure helper
- encodeOidbEnv<T>(env) pass-through
- decodeOidbEnv<T>(bytes) pass-through
- runOidb(bridge, cmd, envelopeBytes) non-generic raw
`encodeOidbEnv` / `decodeOidbEnv` are pure pass-through generic
wrappers — proton wrapper-binds them and substitutes every call site
with the inlined `protobuf_encode_OidbBase__X` / `protobuf_decode_…`
function. `runOidb` is non-generic (proton leaves it alone) so it can
be mocked in tests. `makeOidbEnvelope` is plain TS — also mockable for
introspection.
56 `runOidb` call sites across 11 files migrated to the new API:
- bridge-contacts.ts, actions/extras.ts, actions/friend.ts,
actions/group-admin.ts, actions/group-file.ts,
actions/group-message.ts, actions/interaction.ts,
actions/misc.ts, actions/profile.ts, web-actions/cookies.ts,
highway/pipeline.ts
pipeline.ts also drops `makeOidbBaseSchema(NTV2UploadRichMediaReqSchema)`
and the residual `protoEncode({...}, EncodableMediaMsgInfoSchema)` —
both go through proton now.
Tests:
- 8 test files migrated from `vi.mocked(decodeOidbEnv).mockReturnValueOnce`
to `vi.mocked(runOidb).mockResolvedValueOnce(protobuf_encode<OidbBase<X>>({body: …}))`
— the proton substitution means the old mock layer is bypassed at
build time, so the only mockable point is the bytes layer at `runOidb`.
- 2 new parity tests pinning `OidbBase<T>` ↔ legacy
`makeOidbBaseSchema(InnerSchema)` byte equivalence.
Verification:
- @snowluma/proton: 95/95 tests pass, tsc --noEmit clean
- @snowluma/core: 605/605 tests pass (network-manager.test.ts
fails to load due to a missing darwin-arm64 native binary in this
environment — pre-existing), tsc --noEmit clean
This commit is contained in:
25 files changed
+1144
-977
No files matched your search
@@ -4,42 +4,33 @@
|
||||
// the NTQQ NodeIKernel — every wire trip is one runOidb round-trip.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
OidbGroupTodoSchema,
|
||||
OidbStrangerStatusReqSchema,
|
||||
OidbStrangerStatusRespSchema,
|
||||
OidbAiVoiceListReqSchema,
|
||||
OidbAiVoiceListRespSchema,
|
||||
OidbAiVoiceReqSchema,
|
||||
OidbAiVoiceRespSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv, decodeOidbEnv } from '../bridge-oidb';
|
||||
import type {
|
||||
OidbAiVoiceListReq,
|
||||
OidbAiVoiceListResp,
|
||||
OidbAiVoiceReq,
|
||||
OidbAiVoiceResp,
|
||||
OidbGroupTodo,
|
||||
OidbStrangerStatusReq,
|
||||
OidbStrangerStatusResp,
|
||||
} from '../proto/proton/oidb-action';
|
||||
import type { MediaIndexNode } from './shared';
|
||||
|
||||
// ─────────────── Group todo (0xF90) ───────────────
|
||||
|
||||
export async function setGroupTodo(bridge: Bridge, groupId: number, msgSeq: bigint): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf90_1',
|
||||
oidbCmd: 0xF90, subCmd: 1,
|
||||
request: { schema: OidbGroupTodoSchema, value: { groupUin: groupId, msgSeq } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbGroupTodo>(0xF90, 1, { groupUin: groupId, msgSeq });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xf90_1', encodeOidbEnv<OidbGroupTodo>(env));
|
||||
}
|
||||
|
||||
export async function completeGroupTodo(bridge: Bridge, groupId: number, msgSeq: bigint): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf90_2',
|
||||
oidbCmd: 0xF90, subCmd: 2,
|
||||
request: { schema: OidbGroupTodoSchema, value: { groupUin: groupId, msgSeq } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbGroupTodo>(0xF90, 2, { groupUin: groupId, msgSeq });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xf90_2', encodeOidbEnv<OidbGroupTodo>(env));
|
||||
}
|
||||
|
||||
export async function cancelGroupTodo(bridge: Bridge, groupId: number, msgSeq: bigint): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf90_3',
|
||||
oidbCmd: 0xF90, subCmd: 3,
|
||||
request: { schema: OidbGroupTodoSchema, value: { groupUin: groupId, msgSeq } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbGroupTodo>(0xF90, 3, { groupUin: groupId, msgSeq });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xf90_3', encodeOidbEnv<OidbGroupTodo>(env));
|
||||
}
|
||||
|
||||
// ─────────────── Stranger online/ext status (0xFE1_2) ───────────────
|
||||
@@ -60,18 +51,15 @@ export interface StrangerStatus {
|
||||
*/
|
||||
export async function getStrangerStatus(bridge: Bridge, uin: number): Promise<StrangerStatus | null> {
|
||||
try {
|
||||
const resp = await runOidb<{ data?: { status?: { value?: bigint | number } } }>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xfe1_2',
|
||||
oidbCmd: 0xFE1, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbStrangerStatusReqSchema,
|
||||
value: { uin, key: [{ key: 27372 }] },
|
||||
// Same UIN-form flag fetchUserProfile sets — without it newer
|
||||
// QQ NT rejects with `[oidb] one of uid/openid is invaild`.
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbStrangerStatusRespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbStrangerStatusReq>(
|
||||
0xFE1, 2,
|
||||
{ uin, key: [{ key: 27372 }] } as any,
|
||||
// Same UIN-form flag fetchUserProfile sets — without it newer
|
||||
// QQ NT rejects with `[oidb] one of uid/openid is invaild`.
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0xfe1_2', encodeOidbEnv<OidbStrangerStatusReq>(env));
|
||||
const resp = decodeOidbEnv<OidbStrangerStatusResp>(respBytes).body;
|
||||
const raw = resp?.data?.status?.value;
|
||||
if (raw === undefined || raw === null) return null;
|
||||
const extBig = typeof raw === 'bigint' ? raw : BigInt(raw);
|
||||
@@ -110,13 +98,10 @@ export async function fetchAiVoiceList(
|
||||
groupId: number,
|
||||
chatType: AiVoiceChatType,
|
||||
): Promise<AiVoiceCategory[]> {
|
||||
const resp = await runOidb<{ content?: AiVoiceCategory[] }>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x929d_0',
|
||||
oidbCmd: 0x929D, subCmd: 0,
|
||||
request: { schema: OidbAiVoiceListReqSchema, value: { groupUin: groupId, chatType } },
|
||||
response: { schema: OidbAiVoiceListRespSchema },
|
||||
});
|
||||
return resp?.content ?? [];
|
||||
const env = makeOidbEnvelope<OidbAiVoiceListReq>(0x929D, 0, { groupUin: groupId, chatType });
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x929d_0', encodeOidbEnv<OidbAiVoiceListReq>(env));
|
||||
const resp = decodeOidbEnv<OidbAiVoiceListResp>(respBytes).body;
|
||||
return (resp?.content as AiVoiceCategory[] | undefined) ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,19 +124,13 @@ export async function fetchAiVoice(
|
||||
// Random 32-bit session id — server uses this to deduplicate polls.
|
||||
const sessionId = Math.floor(Math.random() * 0xFFFFFFFF) >>> 0;
|
||||
for (let i = 0; i < maxRetries; i++) {
|
||||
const resp = await runOidb<{
|
||||
statusCode?: number;
|
||||
msgInfo?: { msgInfoBody?: Array<{ index?: MediaIndexNode }> };
|
||||
}>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x929b_0',
|
||||
oidbCmd: 0x929B, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbAiVoiceReqSchema,
|
||||
value: { groupUin: groupId, voiceId, text, chatType, session: { sessionId } },
|
||||
},
|
||||
response: { schema: OidbAiVoiceRespSchema },
|
||||
});
|
||||
const node = resp?.msgInfo?.msgInfoBody?.[0]?.index;
|
||||
const env = makeOidbEnvelope<OidbAiVoiceReq>(
|
||||
0x929B, 0,
|
||||
{ groupUin: groupId, voiceId, text, chatType, session: { sessionId } },
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x929b_0', encodeOidbEnv<OidbAiVoiceReq>(env));
|
||||
const resp = decodeOidbEnv<OidbAiVoiceResp>(respBytes).body;
|
||||
const node = resp?.msgInfo?.msgInfoBody?.[0]?.index as MediaIndexNode | undefined;
|
||||
if (node) return node;
|
||||
}
|
||||
throw new Error(`AI voice synthesis did not complete after ${maxRetries} polls`);
|
||||
|
||||
@@ -3,50 +3,41 @@
|
||||
// protocol uses opaque UIDs rather than QQ uin numbers.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
OidbDeleteFriendSchema,
|
||||
OidbFriendRequestActionSchema,
|
||||
OidbSetFriendRemarkSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv } from '../bridge-oidb';
|
||||
import type {
|
||||
OidbDeleteFriend,
|
||||
OidbFriendRequestAction,
|
||||
OidbSetFriendRemark,
|
||||
} from '../proto/proton/oidb-action';
|
||||
|
||||
export async function setFriendAddRequest(bridge: Bridge, uidOrFlag: string, approve: boolean): Promise<void> {
|
||||
let targetUid = uidOrFlag;
|
||||
if (/^\d+$/.test(uidOrFlag)) {
|
||||
targetUid = await bridge.resolveUserUid(parseInt(uidOrFlag, 10));
|
||||
}
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xb5d_44',
|
||||
oidbCmd: 0xB5D, subCmd: 44,
|
||||
request: { schema: OidbFriendRequestActionSchema, value: { accept: approve ? 3 : 5, targetUid } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbFriendRequestAction>(0xB5D, 44, { accept: approve ? 3 : 5, targetUid });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xb5d_44', encodeOidbEnv<OidbFriendRequestAction>(env));
|
||||
}
|
||||
|
||||
export async function deleteFriend(bridge: Bridge, userId: number, block = false): Promise<void> {
|
||||
const targetUid = await bridge.resolveUserUid(userId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x126b_0',
|
||||
oidbCmd: 0x126B, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbDeleteFriendSchema,
|
||||
value: {
|
||||
field1: {
|
||||
targetUid,
|
||||
field2: {
|
||||
field1: 130,
|
||||
field2: 109,
|
||||
field3: {
|
||||
field1: 8,
|
||||
field2: 8,
|
||||
field3: 50,
|
||||
},
|
||||
},
|
||||
block,
|
||||
field4: false,
|
||||
const env = makeOidbEnvelope<OidbDeleteFriend>(0x126B, 0, {
|
||||
field1: {
|
||||
targetUid,
|
||||
field2: {
|
||||
field1: 130,
|
||||
field2: 109,
|
||||
field3: {
|
||||
field1: 8,
|
||||
field2: 8,
|
||||
field3: 50,
|
||||
},
|
||||
},
|
||||
block,
|
||||
field4: false,
|
||||
},
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x126b_0', encodeOidbEnv<OidbDeleteFriend>(env));
|
||||
|
||||
// Refresh friend cache after deletion so subsequent reads don't
|
||||
// surface a ghost entry. Best-effort: a transient OIDB hiccup here
|
||||
@@ -56,9 +47,6 @@ export async function deleteFriend(bridge: Bridge, userId: number, block = false
|
||||
|
||||
export async function setFriendRemark(bridge: Bridge, userId: number, remark: string): Promise<void> {
|
||||
const uid = await bridge.resolveUserUid(userId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xb6e_2',
|
||||
oidbCmd: 0xB6E, subCmd: 2,
|
||||
request: { schema: OidbSetFriendRemarkSchema, value: { targetUid: uid, remark } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbSetFriendRemark>(0xB6E, 2, { targetUid: uid, remark });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xb6e_2', encodeOidbEnv<OidbSetFriendRemark>(env));
|
||||
}
|
||||
@@ -4,72 +4,56 @@
|
||||
// so callers can grep across the two layers.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
Oidb0x89a_0AddOptionSchema,
|
||||
Oidb0x89a_0SearchSchema,
|
||||
Oidb0x8a0ReqSchema,
|
||||
Oidb0x8a7ReqSchema,
|
||||
Oidb0x8a7RespSchema,
|
||||
OidbGroupRequestActionSchema,
|
||||
OidbKickMemberSchema,
|
||||
OidbLeaveGroupSchema,
|
||||
OidbMuteAllSchema,
|
||||
OidbMuteMemberSchema,
|
||||
OidbRenameGroupSchema,
|
||||
OidbRenameMemberSchema,
|
||||
OidbSetAdminSchema,
|
||||
OidbSpecialTitleSchema,
|
||||
Oidb0xf16ReqSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv, decodeOidbEnv } from '../bridge-oidb';
|
||||
import type {
|
||||
Oidb0x89a_0AddOption,
|
||||
Oidb0x89a_0Search,
|
||||
Oidb0x8a0Req,
|
||||
Oidb0x8a7Req,
|
||||
Oidb0x8a7Resp,
|
||||
Oidb0xf16Req,
|
||||
OidbGroupRequestAction,
|
||||
OidbKickMember,
|
||||
OidbLeaveGroup,
|
||||
OidbMuteAll,
|
||||
OidbMuteMember,
|
||||
OidbRenameGroup,
|
||||
OidbRenameMember,
|
||||
OidbSetAdmin,
|
||||
OidbSpecialTitle,
|
||||
} from '../proto/proton/oidb-action';
|
||||
|
||||
// ─────────────── mute / un-mute ───────────────
|
||||
|
||||
export async function muteGroupMember(bridge: Bridge, groupId: number, userId: number, duration: number): Promise<void> {
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x1253_1',
|
||||
oidbCmd: 0x1253, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbMuteMemberSchema,
|
||||
value: { groupUin: groupId, type: 1, body: { targetUid: uid, duration } },
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbMuteMember>(0x1253, 1, {
|
||||
groupUin: groupId, type: 1, body: { targetUid: uid, duration },
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x1253_1', encodeOidbEnv<OidbMuteMember>(env));
|
||||
}
|
||||
|
||||
export async function muteGroupAll(bridge: Bridge, groupId: number, enable: boolean): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_0',
|
||||
oidbCmd: 0x89A, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbMuteAllSchema,
|
||||
value: { groupUin: groupId, muteState: { state: enable ? 0xFFFFFFFF : 0 } },
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbMuteAll>(0x89A, 0, {
|
||||
groupUin: groupId, muteState: { state: enable ? 0xFFFFFFFF : 0 },
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x89a_0', encodeOidbEnv<OidbMuteAll>(env));
|
||||
}
|
||||
|
||||
// ─────────────── join-policy ───────────────
|
||||
|
||||
export async function setGroupAddOption(bridge: Bridge, groupId: number, addType: number): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_0',
|
||||
oidbCmd: 0x89A, subCmd: 0,
|
||||
request: {
|
||||
schema: Oidb0x89a_0AddOptionSchema,
|
||||
value: { groupUin: BigInt(groupId), settings: { addType }, field12: 0 },
|
||||
},
|
||||
const env = makeOidbEnvelope<Oidb0x89a_0AddOption>(0x89A, 0, {
|
||||
groupUin: BigInt(groupId), settings: { addType }, field12: 0,
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x89a_0', encodeOidbEnv<Oidb0x89a_0AddOption>(env));
|
||||
}
|
||||
|
||||
export async function setGroupSearch(bridge: Bridge, groupId: number): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_0',
|
||||
oidbCmd: 0x89A, subCmd: 0,
|
||||
request: {
|
||||
schema: Oidb0x89a_0SearchSchema,
|
||||
value: { groupUin: BigInt(groupId), settings: new Uint8Array(0), field12: 0 },
|
||||
},
|
||||
const env = makeOidbEnvelope<Oidb0x89a_0Search>(0x89A, 0, {
|
||||
groupUin: BigInt(groupId), settings: new Uint8Array(0), field12: 0,
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x89a_0', encodeOidbEnv<Oidb0x89a_0Search>(env));
|
||||
}
|
||||
|
||||
export async function setGroupAddRequest(
|
||||
@@ -78,92 +62,64 @@ export async function setGroupAddRequest(
|
||||
): Promise<void> {
|
||||
const subCmd = filtered ? 2 : 1;
|
||||
const cmd = filtered ? 'OidbSvcTrpcTcp.0x10c8_2' : 'OidbSvcTrpcTcp.0x10c8_1';
|
||||
await runOidb(bridge, {
|
||||
cmd,
|
||||
oidbCmd: 0x10C8, subCmd,
|
||||
request: {
|
||||
schema: OidbGroupRequestActionSchema,
|
||||
value: { accept: approve ? 1 : 2, body: { sequence: BigInt(sequence), eventType, groupUin: groupId, message: reason } },
|
||||
isUid: true,
|
||||
},
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbGroupRequestAction>(
|
||||
0x10C8, subCmd,
|
||||
{ accept: approve ? 1 : 2, body: { sequence: BigInt(sequence), eventType, groupUin: groupId, message: reason } },
|
||||
true,
|
||||
);
|
||||
await runOidb(bridge, cmd, encodeOidbEnv<OidbGroupRequestAction>(env));
|
||||
}
|
||||
|
||||
// ─────────────── kick / leave ───────────────
|
||||
|
||||
export async function kickGroupMember(bridge: Bridge, groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> {
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8a0_1',
|
||||
oidbCmd: 0x8A0, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbKickMemberSchema,
|
||||
value: { groupUin: groupId, targetUid: uid, rejectAddRequest: reject, reason },
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbKickMember>(0x8A0, 1, {
|
||||
groupUin: groupId, targetUid: uid, rejectAddRequest: reject, reason,
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x8a0_1', encodeOidbEnv<OidbKickMember>(env));
|
||||
}
|
||||
|
||||
export async function kickGroupMembers(bridge: Bridge, groupId: number, userIds: number[], reject: boolean): Promise<void> {
|
||||
const targetUids = await Promise.all(userIds.map(userId => bridge.resolveUserUid(userId, groupId)));
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8a0_1',
|
||||
oidbCmd: 0x8A0, subCmd: 1,
|
||||
request: {
|
||||
schema: Oidb0x8a0ReqSchema,
|
||||
value: { groupId: BigInt(groupId), targetUids, rejectAddRequest: reject ? 1 : 0, kickReason: new Uint8Array(0), field12: 0 },
|
||||
},
|
||||
const env = makeOidbEnvelope<Oidb0x8a0Req>(0x8A0, 1, {
|
||||
groupId: BigInt(groupId), targetUids, rejectAddRequest: reject ? 1 : 0, kickReason: new Uint8Array(0), field12: 0,
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x8a0_1', encodeOidbEnv<Oidb0x8a0Req>(env));
|
||||
}
|
||||
|
||||
export async function leaveGroup(bridge: Bridge, groupId: number): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x1097_1',
|
||||
oidbCmd: 0x1097, subCmd: 1,
|
||||
request: { schema: OidbLeaveGroupSchema, value: { groupUin: groupId } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbLeaveGroup>(0x1097, 1, { groupUin: groupId });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x1097_1', encodeOidbEnv<OidbLeaveGroup>(env));
|
||||
}
|
||||
|
||||
// ─────────────── role / display name ───────────────
|
||||
|
||||
export async function setGroupAdmin(bridge: Bridge, groupId: number, userId: number, enable: boolean): Promise<void> {
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x1096_1',
|
||||
oidbCmd: 0x1096, subCmd: 1,
|
||||
request: { schema: OidbSetAdminSchema, value: { groupUin: groupId, uid, isAdmin: enable } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbSetAdmin>(0x1096, 1, { groupUin: groupId, uid, isAdmin: enable });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x1096_1', encodeOidbEnv<OidbSetAdmin>(env));
|
||||
}
|
||||
|
||||
export async function setGroupCard(bridge: Bridge, groupId: number, userId: number, card: string): Promise<void> {
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8fc_3',
|
||||
oidbCmd: 0x8FC, subCmd: 3,
|
||||
request: {
|
||||
schema: OidbRenameMemberSchema,
|
||||
value: { groupUin: groupId, body: { targetUid: uid, targetName: card } },
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbRenameMember>(0x8FC, 3, {
|
||||
groupUin: groupId, body: { targetUid: uid, targetName: card },
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x8fc_3', encodeOidbEnv<OidbRenameMember>(env));
|
||||
}
|
||||
|
||||
export async function setGroupName(bridge: Bridge, groupId: number, name: string): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x89a_15',
|
||||
oidbCmd: 0x89A, subCmd: 15,
|
||||
request: { schema: OidbRenameGroupSchema, value: { groupUin: groupId, body: { targetName: name } } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbRenameGroup>(0x89A, 15, { groupUin: groupId, body: { targetName: name } });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x89a_15', encodeOidbEnv<OidbRenameGroup>(env));
|
||||
}
|
||||
|
||||
export async function setGroupSpecialTitle(bridge: Bridge, groupId: number, userId: number, title: string): Promise<void> {
|
||||
const uid = await bridge.resolveUserUid(userId, groupId);
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8fc_2',
|
||||
oidbCmd: 0x8FC, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbSpecialTitleSchema,
|
||||
value: { groupUin: groupId, body: { targetUid: uid, specialTitle: title, expireTime: -1 } },
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbSpecialTitle>(0x8FC, 2, {
|
||||
groupUin: groupId, body: { targetUid: uid, specialTitle: title, expireTime: -1 },
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x8fc_2', encodeOidbEnv<OidbSpecialTitle>(env));
|
||||
}
|
||||
|
||||
// ─────────────── personal-side metadata ───────────────
|
||||
@@ -172,11 +128,8 @@ export async function setGroupSpecialTitle(bridge: Bridge, groupId: number, user
|
||||
// here rather than in friend.ts because the semantic is "operate on a
|
||||
// group" rather than "operate on a contact list".
|
||||
export async function setGroupRemark(bridge: Bridge, groupId: number, remark: string): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xf16_1',
|
||||
oidbCmd: 0xF16, subCmd: 1,
|
||||
request: { schema: Oidb0xf16ReqSchema, value: { inner: { groupId: BigInt(groupId), remark }, field12: 0 } },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0xf16Req>(0xF16, 1, { inner: { groupId: BigInt(groupId), remark }, field12: 0 });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xf16_1', encodeOidbEnv<Oidb0xf16Req>(env));
|
||||
}
|
||||
|
||||
// ─────────────── group-level quota query ───────────────
|
||||
@@ -194,12 +147,9 @@ export async function getGroupAtAllRemain(
|
||||
type: 0,
|
||||
};
|
||||
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x8a7_0',
|
||||
oidbCmd: 0x8A7, subCmd: 0,
|
||||
request: { schema: Oidb0x8a7ReqSchema, value: req },
|
||||
response: { schema: Oidb0x8a7RespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0x8a7Req>(0x8A7, 0, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x8a7_0', encodeOidbEnv<Oidb0x8a7Req>(env));
|
||||
const result = decodeOidbEnv<Oidb0x8a7Resp>(respBytes).body;
|
||||
|
||||
if (!result) {
|
||||
throw new Error('get group at all remain result empty');
|
||||
@@ -213,4 +163,3 @@ export async function getGroupAtAllRemain(
|
||||
remain_at_all_count_for_uin: Number(result.uinRemain || 0),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,25 +7,25 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protobuf_encode } from '@snowluma/proton';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv, decodeOidbEnv } from '../bridge-oidb';
|
||||
import { fetchHighwaySession, uploadHighwayHttp } from '../highway/highway-client';
|
||||
import { computeHashes, computeMd5, FILE_UPLOAD_MAX_BYTES, loadBinarySource } from '../highway/utils';
|
||||
import {
|
||||
OidbGroupFileCountViewReqSchema,
|
||||
OidbGroupFileCountViewRespSchema,
|
||||
OidbGroupFileFolderReqSchema,
|
||||
OidbGroupFileFolderRespSchema,
|
||||
OidbGroupFileReqSchema,
|
||||
OidbGroupFileRespSchema,
|
||||
OidbGroupFileViewReqSchema,
|
||||
OidbGroupFileViewRespSchema,
|
||||
OidbPrivateFileDownloadReqSchema,
|
||||
OidbPrivateFileDownloadRespSchema,
|
||||
OidbPrivateFileUploadReqSchema,
|
||||
OidbPrivateFileUploadRespSchema,
|
||||
NTV2RichMediaReqSchema,
|
||||
NTV2RichMediaRespSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import type {
|
||||
OidbGroupFileCountViewReq,
|
||||
OidbGroupFileCountViewResp,
|
||||
OidbGroupFileFolderReq,
|
||||
OidbGroupFileFolderResp,
|
||||
OidbGroupFileReq,
|
||||
OidbGroupFileResp,
|
||||
OidbGroupFileViewReq,
|
||||
OidbGroupFileViewResp,
|
||||
OidbPrivateFileDownloadReq,
|
||||
OidbPrivateFileDownloadResp,
|
||||
OidbPrivateFileUploadReq,
|
||||
OidbPrivateFileUploadResp,
|
||||
NTV2RichMediaReq,
|
||||
NTV2RichMediaResp,
|
||||
} from '../proto/proton/oidb-action';
|
||||
import type { FileUploadExt } from '../proto/proton/highway';
|
||||
import { toHexUpper } from '../../utils/hex';
|
||||
import { ensureRetCodeZero, resolveSelfUid, toInt, type MediaIndexNode } from './shared';
|
||||
@@ -242,12 +242,9 @@ async function fetchNtv2DownloadUrl(
|
||||
oidbCmd: number,
|
||||
payload: Record<string, unknown>,
|
||||
): Promise<string> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: serviceCmd,
|
||||
oidbCmd, subCmd: 200,
|
||||
request: { schema: NTV2RichMediaReqSchema, value: payload, isUid: true },
|
||||
response: { schema: NTV2RichMediaRespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<NTV2RichMediaReq>(oidbCmd, 200, payload as any, true);
|
||||
const respBytes = await runOidb(bridge, serviceCmd, encodeOidbEnv<NTV2RichMediaReq>(env));
|
||||
const resp = decodeOidbEnv<NTV2RichMediaResp>(respBytes).body;
|
||||
|
||||
ensureRetCodeZero('ntv2 download', resp?.respHead?.retCode, resp?.respHead?.message, undefined);
|
||||
const domain = typeof resp?.download?.info?.domain === 'string' ? resp.download.info.domain : '';
|
||||
@@ -263,15 +260,12 @@ async function fetchNtv2DownloadUrl(
|
||||
// ─────────────── file count ───────────────
|
||||
|
||||
export async function fetchGroupFileCount(bridge: Bridge, groupId: number): Promise<{ fileCount: number; maxCount: number }> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d8_3',
|
||||
oidbCmd: 0x6D8, subCmd: 3,
|
||||
request: {
|
||||
schema: OidbGroupFileCountViewReqSchema,
|
||||
value: { count: { groupUin: groupId, appId: 7, busId: 0 } },
|
||||
},
|
||||
response: { schema: OidbGroupFileCountViewRespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbGroupFileCountViewReq>(
|
||||
0x6D8, 3,
|
||||
{ count: { groupUin: groupId, appId: 7, busId: 0 } },
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d8_3', encodeOidbEnv<OidbGroupFileCountViewReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileCountViewResp>(respBytes).body;
|
||||
return {
|
||||
fileCount: toInt(resp?.count?.fileCount ?? 0),
|
||||
maxCount: toInt(resp?.count?.maxCount ?? 10000),
|
||||
@@ -296,31 +290,28 @@ export async function uploadGroupFile(
|
||||
const fileName = normalizeUploadFileName(name, loaded.fileName);
|
||||
const hashes = computeHashes(loaded.bytes);
|
||||
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_0',
|
||||
oidbCmd: 0x6D6, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
file: {
|
||||
groupUin: groupId,
|
||||
appId: 4,
|
||||
busId: 102,
|
||||
entrance: 6,
|
||||
targetDirectory: normalizeDirectory(folderId),
|
||||
fileName,
|
||||
localDirectory: `/${fileName}`,
|
||||
fileSize: BigInt(loaded.bytes.length),
|
||||
fileSha1: hashes.sha1,
|
||||
fileSha3: new Uint8Array(0),
|
||||
fileMd5: hashes.md5,
|
||||
field15: true,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileReq>(
|
||||
0x6D6, 0,
|
||||
{
|
||||
file: {
|
||||
groupUin: groupId,
|
||||
appId: 4,
|
||||
busId: 102,
|
||||
entrance: 6,
|
||||
targetDirectory: normalizeDirectory(folderId),
|
||||
fileName,
|
||||
localDirectory: `/${fileName}`,
|
||||
fileSize: BigInt(loaded.bytes.length),
|
||||
fileSha1: hashes.sha1,
|
||||
fileSha3: new Uint8Array(0),
|
||||
fileMd5: hashes.md5,
|
||||
field15: true,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d6_0', encodeOidbEnv<OidbGroupFileReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileResp>(respBytes).body;
|
||||
|
||||
const upload = resp?.upload;
|
||||
if (!upload) throw new Error('group file upload response missing');
|
||||
@@ -389,32 +380,26 @@ export async function uploadPrivateFile(
|
||||
const fileName = normalizeUploadFileName(name, loaded.fileName);
|
||||
const hashes = computeHashes(loaded.bytes);
|
||||
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xe37_1700',
|
||||
oidbCmd: 0xE37, subCmd: 1700,
|
||||
request: {
|
||||
schema: OidbPrivateFileUploadReqSchema,
|
||||
value: {
|
||||
command: 1700,
|
||||
seq: 0,
|
||||
upload: {
|
||||
senderUid: selfUid,
|
||||
receiverUid: targetUid,
|
||||
fileSize: loaded.bytes.length,
|
||||
fileName,
|
||||
md510MCheckSum: md5First10MB(loaded.bytes),
|
||||
sha1CheckSum: hashes.sha1,
|
||||
localPath: '/',
|
||||
md5CheckSum: hashes.md5,
|
||||
sha3CheckSum: new Uint8Array(0),
|
||||
},
|
||||
businessId: 3,
|
||||
clientType: 1,
|
||||
flagSupportMediaPlatform: 1,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbPrivateFileUploadReq>(0xE37, 1700, {
|
||||
command: 1700,
|
||||
seq: 0,
|
||||
upload: {
|
||||
senderUid: selfUid,
|
||||
receiverUid: targetUid,
|
||||
fileSize: loaded.bytes.length,
|
||||
fileName,
|
||||
md510MCheckSum: md5First10MB(loaded.bytes),
|
||||
sha1CheckSum: hashes.sha1,
|
||||
localPath: '/',
|
||||
md5CheckSum: hashes.md5,
|
||||
sha3CheckSum: new Uint8Array(0),
|
||||
},
|
||||
response: { schema: OidbPrivateFileUploadRespSchema },
|
||||
businessId: 3,
|
||||
clientType: 1,
|
||||
flagSupportMediaPlatform: 1,
|
||||
});
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0xe37_1700', encodeOidbEnv<OidbPrivateFileUploadReq>(env));
|
||||
const resp = decodeOidbEnv<OidbPrivateFileUploadResp>(respBytes).body;
|
||||
|
||||
const upload = resp?.upload;
|
||||
if (!upload) throw new Error('private file upload response missing');
|
||||
@@ -463,27 +448,24 @@ export async function fetchGroupFiles(bridge: Bridge, groupId: number, folderId
|
||||
const pageSize = 20;
|
||||
let startIndex = 0;
|
||||
for (let page = 0; page < 200; page++) {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d8_1',
|
||||
oidbCmd: 0x6D8, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbGroupFileViewReqSchema,
|
||||
value: {
|
||||
list: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
targetDirectory,
|
||||
fileCount: pageSize,
|
||||
sortBy: 1,
|
||||
startIndex,
|
||||
field17: 2,
|
||||
field18: 0,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileViewReq>(
|
||||
0x6D8, 1,
|
||||
{
|
||||
list: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
targetDirectory,
|
||||
fileCount: pageSize,
|
||||
sortBy: 1,
|
||||
startIndex,
|
||||
field17: 2,
|
||||
field18: 0,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileViewRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d8_1', encodeOidbEnv<OidbGroupFileViewReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileViewResp>(respBytes).body;
|
||||
|
||||
const list = resp?.list;
|
||||
if (!list) break;
|
||||
@@ -538,23 +520,20 @@ export async function fetchGroupFiles(bridge: Bridge, groupId: number, folderId
|
||||
// ─────────────── url fetch (group / private files) ───────────────
|
||||
|
||||
export async function fetchGroupFileUrl(bridge: Bridge, groupId: number, fileId: string, busId = 102): Promise<string> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_2',
|
||||
oidbCmd: 0x6D6, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
download: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId,
|
||||
fileId,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileReq>(
|
||||
0x6D6, 2,
|
||||
{
|
||||
download: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId,
|
||||
fileId,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d6_2', encodeOidbEnv<OidbGroupFileReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileResp>(respBytes).body;
|
||||
|
||||
const download = resp?.download;
|
||||
if (!download) throw new Error('group file url response missing');
|
||||
@@ -574,29 +553,23 @@ export async function fetchGroupFileUrl(bridge: Bridge, groupId: number, fileId:
|
||||
|
||||
export async function fetchPrivateFileUrl(bridge: Bridge, userId: number, fileId: string, fileHash: string): Promise<string> {
|
||||
const uid = await bridge.resolveUserUid(userId);
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xe37_1200',
|
||||
oidbCmd: 0xE37, subCmd: 1200,
|
||||
request: {
|
||||
schema: OidbPrivateFileDownloadReqSchema,
|
||||
value: {
|
||||
subCommand: 1200,
|
||||
field2: 1,
|
||||
body: {
|
||||
receiverUid: uid,
|
||||
fileUuid: fileId,
|
||||
type: 2,
|
||||
fileHash,
|
||||
t2: 0,
|
||||
},
|
||||
field101: 3,
|
||||
field102: 103,
|
||||
field200: 1,
|
||||
field99999: new Uint8Array([0xC0, 0x85, 0x2C, 0x01]),
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbPrivateFileDownloadReq>(0xE37, 1200, {
|
||||
subCommand: 1200,
|
||||
field2: 1,
|
||||
body: {
|
||||
receiverUid: uid,
|
||||
fileUuid: fileId,
|
||||
type: 2,
|
||||
fileHash,
|
||||
t2: 0,
|
||||
},
|
||||
response: { schema: OidbPrivateFileDownloadRespSchema },
|
||||
field101: 3,
|
||||
field102: 103,
|
||||
field200: 1,
|
||||
field99999: new Uint8Array([0xC0, 0x85, 0x2C, 0x01]),
|
||||
});
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0xe37_1200', encodeOidbEnv<OidbPrivateFileDownloadReq>(env));
|
||||
const resp = decodeOidbEnv<OidbPrivateFileDownloadResp>(respBytes).body;
|
||||
|
||||
const result = resp?.body?.result;
|
||||
const server = typeof result?.server === 'string' ? result.server : '';
|
||||
@@ -611,22 +584,19 @@ export async function fetchPrivateFileUrl(bridge: Bridge, userId: number, fileId
|
||||
// ─────────────── delete / move ───────────────
|
||||
|
||||
export async function deleteGroupFile(bridge: Bridge, groupId: number, fileId: string): Promise<void> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_3',
|
||||
oidbCmd: 0x6D6, subCmd: 3,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
busId: 102,
|
||||
fileId,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileReq>(
|
||||
0x6D6, 3,
|
||||
{
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
busId: 102,
|
||||
fileId,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d6_3', encodeOidbEnv<OidbGroupFileReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileResp>(respBytes).body;
|
||||
|
||||
const result = resp?.delete;
|
||||
if (!result) throw new Error('group file delete response missing');
|
||||
@@ -640,25 +610,22 @@ export async function moveGroupFile(
|
||||
parentDirectory: string,
|
||||
targetDirectory: string,
|
||||
): Promise<void> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d6_5',
|
||||
oidbCmd: 0x6D6, subCmd: 5,
|
||||
request: {
|
||||
schema: OidbGroupFileReqSchema,
|
||||
value: {
|
||||
move: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId: 102,
|
||||
fileId,
|
||||
parentDirectory,
|
||||
targetDirectory,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileReq>(
|
||||
0x6D6, 5,
|
||||
{
|
||||
move: {
|
||||
groupUin: groupId,
|
||||
appId: 7,
|
||||
busId: 102,
|
||||
fileId,
|
||||
parentDirectory,
|
||||
targetDirectory,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d6_5', encodeOidbEnv<OidbGroupFileReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileResp>(respBytes).body;
|
||||
|
||||
const result = resp?.move;
|
||||
if (!result) throw new Error('group file move response missing');
|
||||
@@ -668,22 +635,19 @@ export async function moveGroupFile(
|
||||
// ─────────────── folders ───────────────
|
||||
|
||||
export async function createGroupFileFolder(bridge: Bridge, groupId: number, name: string, parentId = '/'): Promise<void> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d7_0',
|
||||
oidbCmd: 0x6D7, subCmd: 0,
|
||||
request: {
|
||||
schema: OidbGroupFileFolderReqSchema,
|
||||
value: {
|
||||
create: {
|
||||
groupUin: groupId,
|
||||
rootDirectory: normalizeDirectory(parentId),
|
||||
folderName: name,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileFolderReq>(
|
||||
0x6D7, 0,
|
||||
{
|
||||
create: {
|
||||
groupUin: groupId,
|
||||
rootDirectory: normalizeDirectory(parentId),
|
||||
folderName: name,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileFolderRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d7_0', encodeOidbEnv<OidbGroupFileFolderReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileFolderResp>(respBytes).body;
|
||||
|
||||
const result = resp?.create;
|
||||
if (!result) throw new Error('group folder create response missing');
|
||||
@@ -691,21 +655,18 @@ export async function createGroupFileFolder(bridge: Bridge, groupId: number, nam
|
||||
}
|
||||
|
||||
export async function deleteGroupFileFolder(bridge: Bridge, groupId: number, folderId: string): Promise<void> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d7_1',
|
||||
oidbCmd: 0x6D7, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbGroupFileFolderReqSchema,
|
||||
value: {
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileFolderReq>(
|
||||
0x6D7, 1,
|
||||
{
|
||||
delete: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileFolderRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d7_1', encodeOidbEnv<OidbGroupFileFolderReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileFolderResp>(respBytes).body;
|
||||
|
||||
const result = resp?.delete;
|
||||
if (!result) throw new Error('group folder delete response missing');
|
||||
@@ -713,22 +674,19 @@ export async function deleteGroupFileFolder(bridge: Bridge, groupId: number, fol
|
||||
}
|
||||
|
||||
export async function renameGroupFileFolder(bridge: Bridge, groupId: number, folderId: string, newFolderName: string): Promise<void> {
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x6d7_2',
|
||||
oidbCmd: 0x6D7, subCmd: 2,
|
||||
request: {
|
||||
schema: OidbGroupFileFolderReqSchema,
|
||||
value: {
|
||||
rename: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
newFolderName,
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbGroupFileFolderReq>(
|
||||
0x6D7, 2,
|
||||
{
|
||||
rename: {
|
||||
groupUin: groupId,
|
||||
folderId,
|
||||
newFolderName,
|
||||
},
|
||||
isUid: true,
|
||||
},
|
||||
response: { schema: OidbGroupFileFolderRespSchema },
|
||||
});
|
||||
true,
|
||||
);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x6d7_2', encodeOidbEnv<OidbGroupFileFolderReq>(env));
|
||||
const resp = decodeOidbEnv<OidbGroupFileFolderResp>(respBytes).body;
|
||||
|
||||
const result = resp?.rename;
|
||||
if (!result) throw new Error('group folder rename response missing');
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoEncode } from '../../protobuf/decode';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv } from '../bridge-oidb';
|
||||
import {
|
||||
C2CRecallRequestSchema,
|
||||
GroupRecallRequestSchema,
|
||||
OidbEssenceSchema,
|
||||
SsoReadedReportReqSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import type { OidbEssence } from '../proto/proton/oidb-action';
|
||||
|
||||
export async function recallGroupMessage(bridge: Bridge, groupId: number, sequence: number): Promise<void> {
|
||||
const request = protoEncode({
|
||||
@@ -96,9 +96,6 @@ export async function markGroupMessageRead(
|
||||
export async function setGroupEssence(bridge: Bridge, groupId: number, sequence: number, random: number, enable: boolean): Promise<void> {
|
||||
const subCmd = enable ? 1 : 2;
|
||||
const cmd = enable ? 'OidbSvcTrpcTcp.0xeac_1' : 'OidbSvcTrpcTcp.0xeac_2';
|
||||
await runOidb(bridge, {
|
||||
cmd,
|
||||
oidbCmd: 0xEAC, subCmd,
|
||||
request: { schema: OidbEssenceSchema, value: { groupUin: groupId, sequence, random } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbEssence>(0xEAC, subCmd, { groupUin: groupId, sequence, random });
|
||||
await runOidb(bridge, cmd, encodeOidbEnv<OidbEssence>(env));
|
||||
}
|
||||
@@ -3,37 +3,28 @@
|
||||
// edit message content — they're purely social signals.
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import {
|
||||
Oidb0x9083ReqSchema,
|
||||
Oidb0x9083RespSchema,
|
||||
OidbGroupReactionSchema,
|
||||
OidbLikeSchema,
|
||||
OidbPokeSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv, decodeOidbEnv } from '../bridge-oidb';
|
||||
import type {
|
||||
Oidb0x9083Req,
|
||||
Oidb0x9083Resp,
|
||||
OidbGroupReaction,
|
||||
OidbLike,
|
||||
OidbPoke,
|
||||
} from '../proto/proton/oidb-action';
|
||||
|
||||
export async function sendPoke(bridge: Bridge, isGroup: boolean, peerUin: number, targetUin?: number): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xed3_1',
|
||||
oidbCmd: 0xED3, subCmd: 1,
|
||||
request: {
|
||||
schema: OidbPokeSchema,
|
||||
value: {
|
||||
uin: targetUin ?? peerUin,
|
||||
groupUin: isGroup ? peerUin : 0,
|
||||
friendUin: isGroup ? 0 : peerUin,
|
||||
ext: 0,
|
||||
},
|
||||
},
|
||||
const env = makeOidbEnvelope<OidbPoke>(0xED3, 1, {
|
||||
uin: targetUin ?? peerUin,
|
||||
groupUin: isGroup ? peerUin : 0,
|
||||
friendUin: isGroup ? 0 : peerUin,
|
||||
ext: 0,
|
||||
});
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0xed3_1', encodeOidbEnv<OidbPoke>(env));
|
||||
}
|
||||
|
||||
export async function sendLike(bridge: Bridge, userId: number, count: number): Promise<void> {
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x7e5_104',
|
||||
oidbCmd: 0x7E5, subCmd: 104,
|
||||
request: { schema: OidbLikeSchema, value: { targetUin: userId, count } },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbLike>(0x7E5, 104, { targetUin: userId, count });
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x7e5_104', encodeOidbEnv<OidbLike>(env));
|
||||
}
|
||||
|
||||
export async function setGroupReaction(bridge: Bridge, groupId: number, sequence: number, code: string, isSet: boolean): Promise<void> {
|
||||
@@ -44,14 +35,8 @@ export async function setGroupReaction(bridge: Bridge, groupId: number, sequence
|
||||
// type field to pick the right resolution table; omitting it makes
|
||||
// unicode reactions silently fail.
|
||||
const type = code.length > 3 ? 2 : 1;
|
||||
await runOidb(bridge, {
|
||||
cmd,
|
||||
oidbCmd: 0x9082, subCmd,
|
||||
request: {
|
||||
schema: OidbGroupReactionSchema,
|
||||
value: { groupUin: groupId, sequence, code, type },
|
||||
},
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbGroupReaction>(0x9082, subCmd, { groupUin: groupId, sequence, code, type });
|
||||
await runOidb(bridge, cmd, encodeOidbEnv<OidbGroupReaction>(env));
|
||||
}
|
||||
|
||||
export async function getEmojiLikes(
|
||||
@@ -63,7 +48,7 @@ export async function getEmojiLikes(
|
||||
count: number = 10,
|
||||
cookie: string = '',
|
||||
): Promise<{ users: Array<{ uin: number }>, cookie: string, isLast: boolean }> {
|
||||
const req = {
|
||||
const req: any = {
|
||||
groupId: BigInt(groupId),
|
||||
sequence,
|
||||
emojiType,
|
||||
@@ -73,12 +58,9 @@ export async function getEmojiLikes(
|
||||
count,
|
||||
field12: 1,
|
||||
};
|
||||
const resp = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x9083_1',
|
||||
oidbCmd: 0x9083, subCmd: 1,
|
||||
request: { schema: Oidb0x9083ReqSchema, value: req },
|
||||
response: { schema: Oidb0x9083RespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0x9083Req>(0x9083, 1, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x9083_1', encodeOidbEnv<Oidb0x9083Req>(env));
|
||||
const resp = decodeOidbEnv<Oidb0x9083Resp>(respBytes).body;
|
||||
const uin = resp?.inner?.userInfo?.uin;
|
||||
const users = uin ? [{ uin: Number(uin) }] : [];
|
||||
const respCookie = resp?.cookie ? Buffer.from(resp.cookie).toString('base64') : '';
|
||||
|
||||
@@ -4,17 +4,19 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoDecode, protoEncode } from '../../protobuf/decode';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv, decodeOidbEnv } from '../bridge-oidb';
|
||||
import {
|
||||
MiniAppShareReqSchema,
|
||||
MiniAppShareRespSchema,
|
||||
Oidb0x112eReqSchema,
|
||||
Oidb0x112eRespSchema,
|
||||
Oidb0x990ReqSchema,
|
||||
Oidb0x990RespSchema,
|
||||
Oidb0xeb7ReqSchema,
|
||||
Oidb0xeb7RespSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import type {
|
||||
Oidb0x112eReq,
|
||||
Oidb0x112eResp,
|
||||
Oidb0x990Req,
|
||||
Oidb0x990Resp,
|
||||
Oidb0xeb7Req,
|
||||
Oidb0xeb7Resp,
|
||||
} from '../proto/proton/oidb-action';
|
||||
|
||||
export async function translateEn2Zh(
|
||||
bridge: Bridge,
|
||||
@@ -30,12 +32,9 @@ export async function translateEn2Zh(
|
||||
tag12: 1,
|
||||
};
|
||||
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x990_2',
|
||||
oidbCmd: 0x990, subCmd: 2,
|
||||
request: { schema: Oidb0x990ReqSchema, value: req },
|
||||
response: { schema: Oidb0x990RespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0x990Req>(0x990, 2, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x990_2', encodeOidbEnv<Oidb0x990Req>(env));
|
||||
const result = decodeOidbEnv<Oidb0x990Resp>(respBytes).body;
|
||||
|
||||
const resp = result?.translateResp;
|
||||
if (!resp) {
|
||||
@@ -122,12 +121,9 @@ export async function clickInlineKeyboardButton(
|
||||
unknown9: 1,
|
||||
};
|
||||
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x112e_1',
|
||||
oidbCmd: 0x112E, subCmd: 1,
|
||||
request: { schema: Oidb0x112eReqSchema, value: req },
|
||||
response: { schema: Oidb0x112eRespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0x112eReq>(0x112E, 1, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x112e_1', encodeOidbEnv<Oidb0x112eReq>(env));
|
||||
const result = decodeOidbEnv<Oidb0x112eResp>(respBytes).body;
|
||||
|
||||
if (!result) {
|
||||
throw new Error('click inline keyboard button result empty');
|
||||
@@ -155,10 +151,8 @@ export async function sendGroupSign(
|
||||
},
|
||||
};
|
||||
|
||||
await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xEB7_1',
|
||||
oidbCmd: 0xEB7, subCmd: 1,
|
||||
request: { schema: Oidb0xeb7ReqSchema, value: req },
|
||||
response: { schema: Oidb0xeb7RespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0xeb7Req>(0xEB7, 1, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0xEB7_1', encodeOidbEnv<Oidb0xeb7Req>(env));
|
||||
// Decode just to maintain the original behaviour of "consume the response".
|
||||
decodeOidbEnv<Oidb0xeb7Resp>(respBytes);
|
||||
}
|
||||
@@ -4,25 +4,27 @@
|
||||
|
||||
import type { Bridge } from '../bridge';
|
||||
import { protoDecode, protoEncode } from '../../protobuf/decode';
|
||||
import { runOidb } from '../bridge-oidb';
|
||||
import { runOidb, makeOidbEnvelope, encodeOidbEnv, decodeOidbEnv } from '../bridge-oidb';
|
||||
import { fetchHighwaySession, uploadHighwayHttp } from '../highway/highway-client';
|
||||
import { computeHashes, loadBinarySource } from '../highway/utils';
|
||||
import {
|
||||
FaceroamOpReqSchema,
|
||||
FaceroamOpRespSchema,
|
||||
GroupAvatarExtraSchema,
|
||||
Oidb0x112aReqSchema,
|
||||
Oidb0x112aRespSchema,
|
||||
Oidb0x7edReqSchema,
|
||||
Oidb0x7edRespSchema,
|
||||
Oidb0xcd4ReqSchema,
|
||||
Oidb0xcd4RespSchema,
|
||||
Oidb0xe17ReqSchema,
|
||||
Oidb0xe17RespSchema,
|
||||
OidbSetProfileSchema,
|
||||
SetStatusReqSchema,
|
||||
SetStatusRespSchema,
|
||||
} from '../proto/oidb-action';
|
||||
import type {
|
||||
Oidb0x112aReq,
|
||||
Oidb0x112aResp,
|
||||
Oidb0x7edReq,
|
||||
Oidb0x7edResp,
|
||||
Oidb0xcd4Req,
|
||||
Oidb0xcd4Resp,
|
||||
Oidb0xe17Req,
|
||||
Oidb0xe17Resp,
|
||||
OidbSetProfile,
|
||||
} from '../proto/proton/oidb-action';
|
||||
import { resolveSelfUid } from './shared';
|
||||
|
||||
// ─────────────── status / profile setters ───────────────
|
||||
@@ -110,11 +112,8 @@ export async function setProfile(
|
||||
stringProfiles,
|
||||
};
|
||||
|
||||
await runOidb(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x112a_2',
|
||||
oidbCmd: 0x112A, subCmd: 2,
|
||||
request: { schema: OidbSetProfileSchema, value: req },
|
||||
});
|
||||
const env = makeOidbEnvelope<OidbSetProfile>(0x112A, 2, req);
|
||||
await runOidb(bridge, 'OidbSvcTrpcTcp.0x112a_2', encodeOidbEnv<OidbSetProfile>(env));
|
||||
}
|
||||
|
||||
export async function setSelfLongNick(
|
||||
@@ -129,12 +128,10 @@ export async function setSelfLongNick(
|
||||
},
|
||||
};
|
||||
|
||||
await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x112a_2',
|
||||
oidbCmd: 0x112A, subCmd: 2,
|
||||
request: { schema: Oidb0x112aReqSchema, value: req },
|
||||
response: { schema: Oidb0x112aRespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0x112aReq>(0x112A, 2, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x112a_2', encodeOidbEnv<Oidb0x112aReq>(env));
|
||||
// Decode just to maintain the original behaviour of "consume the response".
|
||||
decodeOidbEnv<Oidb0x112aResp>(respBytes);
|
||||
}
|
||||
|
||||
export async function setInputStatus(
|
||||
@@ -156,12 +153,10 @@ export async function setInputStatus(
|
||||
},
|
||||
};
|
||||
|
||||
await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0xcd4_1',
|
||||
oidbCmd: 0xCD4, subCmd: 1,
|
||||
request: { schema: Oidb0xcd4ReqSchema, value: req },
|
||||
response: { schema: Oidb0xcd4RespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0xcd4Req>(0xCD4, 1, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0xcd4_1', encodeOidbEnv<Oidb0xcd4Req>(env));
|
||||
// Decode just to maintain the original behaviour of "consume the response".
|
||||
decodeOidbEnv<Oidb0xcd4Resp>(respBytes);
|
||||
}
|
||||
|
||||
export async function setAvatar(
|
||||
@@ -232,12 +227,9 @@ export async function getProfileLike(
|
||||
limit: limit,
|
||||
};
|
||||
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'OidbSvcTrpcTcp.0x7ed_12',
|
||||
oidbCmd: 0x7ED, subCmd: 12,
|
||||
request: { schema: Oidb0x7edReqSchema, value: req },
|
||||
response: { schema: Oidb0x7edRespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0x7edReq>(0x7ED, 12, req);
|
||||
const respBytes = await runOidb(bridge, 'OidbSvcTrpcTcp.0x7ed_12', encodeOidbEnv<Oidb0x7edReq>(env));
|
||||
const result = decodeOidbEnv<Oidb0x7edResp>(respBytes).body;
|
||||
|
||||
const data = result?.userLikeInfos?.[0];
|
||||
if (!data) {
|
||||
@@ -277,12 +269,9 @@ export async function getUnidirectionalFriendList(
|
||||
jsonBody: JSON.stringify(reqObj),
|
||||
};
|
||||
|
||||
const result = await runOidb<any>(bridge, {
|
||||
cmd: 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0',
|
||||
oidbCmd: 0xE17, subCmd: 0,
|
||||
request: { schema: Oidb0xe17ReqSchema, value: req },
|
||||
response: { schema: Oidb0xe17RespSchema },
|
||||
});
|
||||
const env = makeOidbEnvelope<Oidb0xe17Req>(0xE17, 0, req);
|
||||
const respBytes = await runOidb(bridge, 'MQUpdateSvc_com_qq_ti.web.OidbSvc.0xe17_0', encodeOidbEnv<Oidb0xe17Req>(env));
|
||||
const result = decodeOidbEnv<Oidb0xe17Resp>(respBytes).body;
|
||||
|
||||
if (!result || !result.jsonBody) {
|
||||
throw new Error('get unidirectional friend list empty');
|
||||
|
||||
Reference in new issue
Block a user