fix(onebot): restore group and doubt request accounts

get_group_system_msg now keeps join and invite records, reports the
inviter, and fills a missing requester nick from the user profile.
get_doubt_friends_add_request returns the QQ number plus the request
message, source, and time that QQ actually sends.

Closes #400
Closes #401
Closes #402
Closes #403
This commit is contained in:
DrSmoothl committed 2026-08-19 21:45:15 +08:00
1 parent 5a10fc4c9c
commit 8fdd41ea22
13 files changed
+418 -79

No files matched your search

@@ -627,6 +627,30 @@ describe('onebot/contact-actions / getGroupSystemMessages', () => {
});
});
it('includes admin-approval invitations with the invited account and inviter', async () => {
const bridge = fakeBridge({
fetchGroupRequests: vi.fn(async (filtered: boolean) => filtered ? [] : [
makeGroupRequest({
notifyType: 5,
eventType: 22,
targetUin: 10_001,
targetName: 'invitee',
invitorUin: 45_678,
invitorName: 'inviter',
}),
]),
});
const result = await getGroupSystemMessages(bridge);
expect(result).toEqual([expect.objectContaining({
requester_uin: 10_001,
requester_nick: 'invitee',
invitor_uin: 45_678,
invitor_nick: 'inviter',
})]);
});
it('reports the inviter as requester for group invitations', async () => {
const bridge = fakeBridge({
fetchGroupRequests: vi.fn(async (filtered: boolean) => filtered ? [] : [
@@ -646,6 +670,8 @@ describe('onebot/contact-actions / getGroupSystemMessages', () => {
expect(result).toEqual([expect.objectContaining({
requester_uin: 45_678,
requester_nick: 'inviter',
invitor_uin: 45_678,
invitor_nick: 'inviter',
})]);
});
@@ -2027,7 +2027,10 @@ describe('extended-actions / TierB ③ share + doubt + robot-option', () => {
});
it('get_doubt_friends_add_request returns the mapped list', async () => {
const list = [{ uid: 'u1', nick: 'A', source: 's', msg: 'm', reqTime: 123 }];
const list = [{
uid: 'u1', user_id: 10001, nick: 'A', source: 's', reason: '',
msg: 'm', group_code: '', 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 });
@@ -411,6 +411,34 @@ describe('buildApiContext setMsgEmojiLike', () => {
});
});
describe('buildApiContext fetchEmojiLikeSummary', () => {
it('returns every emoji on the message with cached users', async () => {
const listUsers = vi.fn(() => [
{ operatorUin: 20002, operatorUid: 'u_20002', setAt: 1_700_000_001 },
]);
const fetchReactionSummary = vi.fn(async () => [
{ emojiId: '76', emojiType: 1, count: 1, lastReactionTime: 1_700_000_001 },
]);
const { api, metas } = makeRef({
reactionStore: { listUsers, summarizeMessage: vi.fn(() => []) },
apis: { interaction: { setReaction: vi.fn(), fetchReactionSummary } },
});
metas.set(-20, groupMeta({ targetId: 710301, sequence: 55 }));
await expect(api.fetchEmojiLikeSummary(-20)).resolves.toEqual([
{
emoji_id: '76',
emoji_type: 1,
count: 1,
last_reaction_time: 1_700_000_001,
users: [{ user_id: 20002 }],
},
]);
expect(fetchReactionSummary).toHaveBeenCalledWith(710301, 55);
expect(listUsers).toHaveBeenCalledWith(710301, 55, '76', 1000, 0);
});
});
describe('buildApiContext fetchEmojiLikeUsers', () => {
it('throws when the message is missing', async () => {
const { api } = makeRef();
@@ -770,6 +798,12 @@ describe('buildApiContext contact reads', () => {
long_nick: 'hello sign',
qq_level: 17,
level: 17,
status: 0,
extStatus: 0,
ext_status: 0,
batteryStatus: 0,
customStatus: null,
customStatusDescInfo: '',
});
});
@@ -879,6 +913,8 @@ describe('buildApiContext contact reads', () => {
request_id: 888,
requester_uin: 20002,
requester_nick: 'applicant',
invitor_uin: 30003,
invitor_nick: 'inviter',
message: 'please add',
checked: false,
flag: 'slreq:1:888:710010:22:0',