feat(onebot): TierB ③ — RE'd OIDB actions (ark share / doubt friends / robot-add)
All recovered from QQNT wrapper.linux.node via IDA — NapCat ships these as
kernel-only with no portable packet wire, so each cmd + protobuf was traced
from the binary (worker ctor cmd/subcmd via BaseOidbWorker::DoSendOidbReq;
field tags from the per-feature EncodeRequest). All uin-form OIDB (envelope
reserved=1, matching the NT worker flag=1). One commit for easy rollback.
New OIDB services + byte-oracle tests (fixed-wire, mutation-resistant):
- 0x9130_0 getBuddyRecommendContactArkJson → share_peer/send_ark_share (user)
- 0x8b7_5 getGroupRecommendContactArkJson → share_peer/send_ark_share (group),
share_group_ex/send_group_ark_share (NapCat's getArkJsonGroupShare
was NOT RE'd; routed to this confident equivalent — documented)
- 0xd69_0 getDoubtBuddyReq → get_doubt_friends_add_request
- 0xd69_0 approvalDoubtBuddyReq → set_doubt_friends_add_request (approve only)
- 0xf00_3 modifyGroupExtInfoV2 → set_group_robot_add_option (EXTInfo tags
30/31; GroupExtFilter is client-side gating, not on the wire)
NOT shipped (kernel-.so-side, no static cmd recoverable from this binary —
honest, no guessed packets): get_robot_uin_range (trpc method-routed),
create_collection/get_collection_list (Weiyun multi-step), trans_group_file.
Doubt-list string field NAMES (nick/source/msg) are medium-confidence
(generic serializer); uid+reqTime are high. READ path, so a mislabel is
cosmetic, never a wire/ban risk. Wired through bridge friend/contacts/
groupAdmin apis; proto-defs + per-file subpath exports registered.
This commit is contained in:
21 files changed
+931
No files matched your search
@@ -884,3 +884,78 @@ describe('extended-actions / get_recent_contact stub', () => {
|
||||
expect(res).toMatchObject({ status: 'ok', data: [] });
|
||||
});
|
||||
});
|
||||
|
||||
// ─── TierB ③: RE'd OIDB-backed actions (wiring through handle) ───
|
||||
describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
|
||||
it('share_peer with user_id calls getBuddyRecommendArk and wraps the ark', async () => {
|
||||
const getBuddyRecommendArk = vi.fn(async () => '{"app":"x"}');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getBuddyRecommendArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('share_peer', { user_id: 10000 });
|
||||
expect(getBuddyRecommendArk).toHaveBeenCalledWith(10000, '');
|
||||
expect(res).toMatchObject({ status: 'ok', data: { arkMsg: '{"app":"x"}' } });
|
||||
});
|
||||
|
||||
it('share_peer with group_id calls getGroupRecommendArk', async () => {
|
||||
const getGroupRecommendArk = vi.fn(async () => '{"app":"g"}');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getGroupRecommendArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('share_peer', { group_id: 555 });
|
||||
expect(getGroupRecommendArk).toHaveBeenCalledWith(555);
|
||||
expect(res).toMatchObject({ status: 'ok', data: { arkMsg: '{"app":"g"}' } });
|
||||
});
|
||||
|
||||
it('share_peer with neither id fails', async () => {
|
||||
const res = await makeHandler(fakeCtx(fakeBridge())).handle('share_peer', {});
|
||||
expect(res.status).toBe('failed');
|
||||
});
|
||||
|
||||
it('send_ark_share shares the buddy/group routing', async () => {
|
||||
const getBuddyRecommendArk = vi.fn(async () => 'ARK');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getBuddyRecommendArk } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('send_ark_share', { user_id: 1, phone_number: '99' });
|
||||
expect(getBuddyRecommendArk).toHaveBeenCalledWith(1, '99');
|
||||
expect(res).toMatchObject({ status: 'ok', data: { arkMsg: 'ARK' } });
|
||||
});
|
||||
|
||||
it('share_group_ex / send_group_ark_share return the group ark string', async () => {
|
||||
const getGroupRecommendArk = vi.fn(async () => 'GROUP_ARK');
|
||||
const bridge = fakeBridge({ apis: { contacts: { getGroupRecommendArk } } });
|
||||
for (const name of ['share_group_ex', 'send_group_ark_share']) {
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle(name, { group_id: 42 });
|
||||
expect(res).toMatchObject({ status: 'ok', data: 'GROUP_ARK' });
|
||||
}
|
||||
expect(getGroupRecommendArk).toHaveBeenCalledWith(42);
|
||||
});
|
||||
|
||||
it('get_doubt_friends_add_request returns the mapped list', async () => {
|
||||
const list = [{ uid: 'u1', nick: 'A', source: 's', msg: 'm', reqTime: 123 }];
|
||||
const getDoubtRequests = vi.fn(async () => list);
|
||||
const bridge = fakeBridge({ apis: { friend: { getDoubtRequests } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('get_doubt_friends_add_request', { count: 5 });
|
||||
expect(getDoubtRequests).toHaveBeenCalledWith(5);
|
||||
expect(res).toMatchObject({ status: 'ok', data: list });
|
||||
});
|
||||
|
||||
it('set_doubt_friends_add_request approves by flag (uid)', async () => {
|
||||
const approveDoubtRequest = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { friend: { approveDoubtRequest } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('set_doubt_friends_add_request', { flag: 'u_abc', approve: true });
|
||||
expect(approveDoubtRequest).toHaveBeenCalledWith('u_abc');
|
||||
expect(res).toMatchObject({ status: 'ok' });
|
||||
});
|
||||
|
||||
it('set_doubt_friends_add_request rejects approve:false instead of silently approving', async () => {
|
||||
const approveDoubtRequest = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { friend: { approveDoubtRequest } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('set_doubt_friends_add_request', { flag: 'u_abc', approve: false });
|
||||
expect(res.status).toBe('failed');
|
||||
expect(approveDoubtRequest).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('set_group_robot_add_option forwards group + switch/examine', async () => {
|
||||
const setRobotAddOption = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({ apis: { groupAdmin: { setRobotAddOption } } });
|
||||
const res = await makeHandler(fakeCtx(bridge)).handle('set_group_robot_add_option', { group_id: 12345, robot_member_switch: 1, robot_member_examine: 2 });
|
||||
expect(setRobotAddOption).toHaveBeenCalledWith(12345, 1, 2);
|
||||
expect(res).toMatchObject({ status: 'ok' });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user