11 files changed
+315
-176
No files matched your search
@@ -3,7 +3,7 @@ import { mapWithConcurrency } from '@snowluma/common/concurrency';
|
||||
import { positiveIntEnv } from '@snowluma/common/env';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { FriendDressError } from '@snowluma/protocol/web/friend-dress';
|
||||
import { formatGroupRequestFlag } from '@snowluma/protocol/qq-info';
|
||||
import { formatGroupRequestFlag, groupRequestSubType } from '@snowluma/protocol/qq-info';
|
||||
import type {
|
||||
GroupEssenceContent,
|
||||
GroupEssenceMessage,
|
||||
@@ -5486,7 +5486,8 @@ export const actions = [
|
||||
// 与标准群系统消息共用过滤收件箱,只保留方言动作的返回形状。
|
||||
// 这几个动作只是为实际使用中的 OneBot 方言客户端重命名并投影相同数据。
|
||||
async function fetchFilteredGroupRequests(ctx: ApiActionContext) {
|
||||
return ctx.bridge.apis.contacts.fetchGroupRequests(true);
|
||||
const requests = await ctx.bridge.apis.contacts.fetchGroupRequests(true);
|
||||
return requests.filter((request) => groupRequestSubType(request) !== undefined);
|
||||
}
|
||||
|
||||
function parseDownloadHeaders(headers: unknown): Record<string, string> {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from '@snowluma/protocol/dataline/device-contacts';
|
||||
import {
|
||||
formatGroupRequestFlag,
|
||||
groupRequestSubType,
|
||||
isSelfGroupInvitation,
|
||||
type GroupMemberInfo,
|
||||
type GroupRequestInfo,
|
||||
@@ -589,18 +590,6 @@ async function resolveRequesterUins(
|
||||
return resolved;
|
||||
}
|
||||
|
||||
/** Join requests, self invitations, and invitations awaiting administrator approval. */
|
||||
function isJoinOrInviteNotify(notifyType: number | undefined): boolean {
|
||||
return (
|
||||
notifyType === undefined ||
|
||||
notifyType === 1 ||
|
||||
notifyType === 2 ||
|
||||
notifyType === 5 ||
|
||||
notifyType === 7 ||
|
||||
notifyType === 22
|
||||
);
|
||||
}
|
||||
|
||||
function groupRequestActor(request: GroupRequestInfo): {
|
||||
uid: string;
|
||||
uin: number;
|
||||
@@ -638,11 +627,7 @@ export async function getGroupSystemMessages(
|
||||
const unique = new Map<string, GroupRequestInfo>();
|
||||
|
||||
for (const request of [...main, ...filtered]) {
|
||||
if (!isJoinOrInviteNotify(request.notifyType)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (request.eventType <= 0) {
|
||||
if (!groupRequestSubType(request)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createLogger } from '@snowluma/common/logger';
|
||||
import type { BridgeInterface } from '@snowluma/core/bridge-interface';
|
||||
import {
|
||||
groupRequestSubType,
|
||||
isSelfGroupInvitation,
|
||||
type GroupRequestHandle,
|
||||
type GroupRequestInfo,
|
||||
@@ -141,10 +142,7 @@ async function resolveLiveGroupRequest(
|
||||
|
||||
const lookup = await fetchRequestInboxes(bridge, 'uin');
|
||||
const live = lookup.requests.find(
|
||||
(request) =>
|
||||
request.groupId === handle.groupId &&
|
||||
request.sequence === handle.sequence &&
|
||||
request.eventType > 0,
|
||||
(request) => request.groupId === handle.groupId && request.sequence === handle.sequence,
|
||||
);
|
||||
|
||||
if (!live) {
|
||||
@@ -168,6 +166,13 @@ async function applyGroupRequest(
|
||||
knownLive?: GroupRequestInfo,
|
||||
): Promise<void> {
|
||||
const live = knownLive ?? (await resolveLiveGroupRequest(bridge, handle));
|
||||
|
||||
if (!groupRequestSubType(live)) {
|
||||
throw new Error(
|
||||
`unsupported group request type: group=${live.groupId} sequence=${live.sequence} type=${live.eventType}`,
|
||||
);
|
||||
}
|
||||
|
||||
log.debug(
|
||||
'handling group request: group=%d sequence=%d eventType=%d filtered=%s approve=%s',
|
||||
live.groupId,
|
||||
@@ -263,7 +268,11 @@ export async function handleGroupAddRequest(
|
||||
|
||||
const lookup = await fetchRequestInboxes(bridge, 'uid');
|
||||
const candidates = lookup.requests.filter((request) => {
|
||||
if (request.groupId !== parsed.groupId || request.state !== 1 || request.eventType <= 0) {
|
||||
if (
|
||||
request.groupId !== parsed.groupId ||
|
||||
request.state !== 1 ||
|
||||
groupRequestSubType(request) !== parsed.requestType
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1300,7 +1300,7 @@ function fakeFilteredRequest(overrides: Partial<GroupRequestInfo> = {}): GroupRe
|
||||
operatorName: 'op',
|
||||
sequence: 42,
|
||||
state: 1,
|
||||
eventType: 7,
|
||||
eventType: 1,
|
||||
comment: 'pls',
|
||||
filtered: true,
|
||||
...overrides,
|
||||
@@ -1310,7 +1310,9 @@ function fakeFilteredRequest(overrides: Partial<GroupRequestInfo> = {}): GroupRe
|
||||
describe('extended-actions / get_group_ignored_notifies', () => {
|
||||
it('maps filtered fetchGroupRequests(true) into the napcat shape', async () => {
|
||||
const fetchGroupRequests = vi.fn(async (filtered: boolean) =>
|
||||
filtered ? [fakeFilteredRequest()] : [],
|
||||
filtered
|
||||
? [fakeFilteredRequest(), fakeFilteredRequest({ sequence: 43, eventType: 7 })]
|
||||
: [],
|
||||
);
|
||||
const bridge = fakeBridge({ fetchGroupRequests: fetchGroupRequests as any });
|
||||
const h = makeHandler(fakeCtx(bridge));
|
||||
@@ -1329,7 +1331,7 @@ describe('extended-actions / get_group_ignored_notifies', () => {
|
||||
actor: 8888,
|
||||
invitor_uin: 7777,
|
||||
invitor_nick: 'inviter',
|
||||
flag: 'slreq:1:42:999:7:1',
|
||||
flag: 'slreq:1:42:999:1:1',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { Bridge } from '@snowluma/core/bridge';
|
||||
import { IdentityService } from '@snowluma/protocol/identity-service';
|
||||
import type { GroupInviteEvent } from '@snowluma/protocol/events';
|
||||
import { MSG_PUSH_CMD } from '@snowluma/protocol/msg-push';
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { PushMsg } from '@snowluma/proto-defs/message';
|
||||
import type { GroupInvite } from '@snowluma/proto-defs/notify';
|
||||
import type { OidbBase, OidbSvcTrpcTcp0x10C0Response } from '@snowluma/proto-defs/oidb';
|
||||
import type { GroupInvitation, GroupInvite, GroupJoin } from '@snowluma/proto-defs/notify';
|
||||
import type {
|
||||
OidbBase,
|
||||
OidbSvcTrpcTcp0x10C0Response,
|
||||
OidbSvcTrpcTcp0x10C0ResponseRequest,
|
||||
} from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupRequestAction } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { convertEvent } from '../src/event-converter';
|
||||
import { getGroupSystemMessages } from '../src/modules/contact-actions';
|
||||
import { handleGroupAddRequest } from '../src/modules/request-actions';
|
||||
|
||||
@@ -16,7 +22,7 @@ afterEach(async () => {
|
||||
await Promise.all(bridges.splice(0).map((bridge) => bridge.dispose()));
|
||||
});
|
||||
|
||||
function setup(filtered = false, overrides: { targetUid?: string; state?: number } = {}) {
|
||||
function setup(filtered = false, overrides: OidbSvcTrpcTcp0x10C0ResponseRequest = {}) {
|
||||
const bridge = new Bridge(IdentityService.memory('10001'));
|
||||
bridges.push(bridge);
|
||||
bridge.identity.setSelfProfile({
|
||||
@@ -36,15 +42,15 @@ function setup(filtered = false, overrides: { targetUid?: string; state?: number
|
||||
});
|
||||
bridge.identity.rememberRequestIdentity({ groupId: 999, uid: 'u_self', uin: 10001 });
|
||||
bridge.identity.rememberRequestIdentity({ groupId: 999, uid: 'u_inviter', uin: 456 });
|
||||
const operateTransInfo = Uint8Array.from([8, 42, 16, 231, 7, 24, 2]);
|
||||
const record = {
|
||||
sequence: 42n,
|
||||
eventType: 2,
|
||||
state: overrides.state ?? 1,
|
||||
state: 1,
|
||||
group: { groupUin: 999, groupName: 'group' },
|
||||
target: { uid: overrides.targetUid ?? 'u_self', name: 'bot' },
|
||||
target: { uid: 'u_self', name: 'bot' },
|
||||
invitor: { uid: 'u_inviter', name: 'inviter' },
|
||||
operateTransInfo,
|
||||
operateTransInfo: Uint8Array.from([8, 42, 16, 231, 7, 24, 2]),
|
||||
...overrides,
|
||||
};
|
||||
const send = vi.spyOn(bridge, 'sendRawPacket').mockImplementation(async (cmd) => {
|
||||
let responseData = Buffer.alloc(0);
|
||||
@@ -61,9 +67,12 @@ function setup(filtered = false, overrides: { targetUid?: string; state?: number
|
||||
|
||||
return { success: true, gotResponse: true, errorCode: 0, errorMessage: '', responseData };
|
||||
});
|
||||
const flags: string[] = [];
|
||||
bridge.events.on('group_invite', (event) => flags.push(event.flag));
|
||||
const notice = () =>
|
||||
const events: GroupInviteEvent[] = [];
|
||||
bridge.events.on('group_invite', (event) => events.push(event));
|
||||
const notice = (
|
||||
msgType = 87,
|
||||
msgContent = protobuf_encode<GroupInvite>({ groupUin: 999, invitorUid: 'u_inviter' }),
|
||||
) =>
|
||||
bridge.onPacket({
|
||||
pid: 1,
|
||||
uin: '10001',
|
||||
@@ -74,36 +83,108 @@ function setup(filtered = false, overrides: { targetUid?: string; state?: number
|
||||
body: Buffer.from(
|
||||
protobuf_encode<PushMsg>({
|
||||
message: {
|
||||
contentHead: { msgType: 87, timestamp: 1 },
|
||||
body: {
|
||||
msgContent: protobuf_encode<GroupInvite>({
|
||||
groupUin: 999,
|
||||
invitorUid: 'u_inviter',
|
||||
}),
|
||||
},
|
||||
contentHead: { msgType, timestamp: 1 },
|
||||
body: { msgContent },
|
||||
},
|
||||
status: 0,
|
||||
}),
|
||||
),
|
||||
});
|
||||
return { bridge, send, flags, notice, operateTransInfo };
|
||||
return { bridge, send, events, notice, operateTransInfo: record.operateTransInfo };
|
||||
}
|
||||
|
||||
describe('group join requests', () => {
|
||||
it.each([false, true])(
|
||||
'reports and handles a join from the inbox (filtered=%s)',
|
||||
async (filtered) => {
|
||||
const { bridge, send, events, notice, operateTransInfo } = setup(filtered, {
|
||||
eventType: 1,
|
||||
target: { uid: 'u_applicant', name: 'applicant' },
|
||||
invitor: undefined,
|
||||
comment: 'please let me in',
|
||||
operateTransInfo: Uint8Array.from([8, 42, 16, 231, 7, 24, 1]),
|
||||
});
|
||||
bridge.identity.rememberRequestIdentity({ groupId: 999, uid: 'u_applicant', uin: 123 });
|
||||
await notice(
|
||||
84,
|
||||
protobuf_encode<GroupJoin>({ groupUin: 999, targetUid: 'u_applicant' }),
|
||||
);
|
||||
|
||||
expect(events).toHaveLength(1);
|
||||
const flag = `slreq:1:42:999:1:${filtered ? 1 : 0}`;
|
||||
const event = await convertEvent(
|
||||
{
|
||||
selfId: 10001,
|
||||
imageUrlResolver: null,
|
||||
mediaUrlResolver: null,
|
||||
messageIdResolver: null,
|
||||
mediaSegmentSink: null,
|
||||
},
|
||||
events[0]!,
|
||||
);
|
||||
expect(event).toMatchObject({
|
||||
post_type: 'request',
|
||||
request_type: 'group',
|
||||
sub_type: 'add',
|
||||
group_id: 999,
|
||||
user_id: 123,
|
||||
comment: 'please let me in',
|
||||
flag,
|
||||
});
|
||||
expect(await getGroupSystemMessages(bridge, { onlyPending: true })).toEqual([
|
||||
expect.objectContaining({ requester_uin: 123, requester_nick: 'applicant', flag }),
|
||||
]);
|
||||
|
||||
await handleGroupAddRequest(bridge, events[0]!.flag, true, '');
|
||||
const approvals = send.mock.calls.filter(([cmd]) =>
|
||||
cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'),
|
||||
);
|
||||
expect(approvals).toHaveLength(1);
|
||||
const [cmd, bytes] = approvals[0]!;
|
||||
expect(cmd).toBe(`OidbSvcTrpcTcp.0x10c8_${filtered ? 2 : 1}`);
|
||||
expect(protobuf_decode<OidbBase<OidbGroupRequestAction>>(bytes).body).toMatchObject({
|
||||
accept: 1,
|
||||
body: { sequence: 42n, groupUin: 999, eventType: 1, operateTransInfo },
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.each([7, 10, 5])('does not report another wire type (%i) as a join', async (eventType) => {
|
||||
const { bridge, events, notice } = setup(false, { eventType });
|
||||
await notice(84, protobuf_encode<GroupJoin>({ groupUin: 999, targetUid: 'u_self' }));
|
||||
expect(events).toEqual([]);
|
||||
expect(await getGroupSystemMessages(bridge)).toEqual([]);
|
||||
});
|
||||
|
||||
it.each(['42', 'slreq:1:42:999:1:0'])(
|
||||
'refuses an unknown inbox type for flag %s',
|
||||
async (flag) => {
|
||||
const { bridge, send } = setup(false, { eventType: 5 });
|
||||
await expect(handleGroupAddRequest(bridge, flag, true, '')).rejects.toThrow(
|
||||
'unsupported group request type',
|
||||
);
|
||||
expect(send.mock.calls.some(([cmd]) => cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'))).toBe(
|
||||
false,
|
||||
);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('non-friend group invitations', () => {
|
||||
it.each([
|
||||
{ approve: true, filtered: false },
|
||||
{ approve: false, filtered: true },
|
||||
])('handles an emitted flag through the real codecs: %j', async ({ approve, filtered }) => {
|
||||
const { bridge, send, flags, notice, operateTransInfo } = setup(filtered);
|
||||
const { bridge, send, events, notice, operateTransInfo } = setup(filtered);
|
||||
await notice();
|
||||
expect(flags).toEqual(['invite:999:u_inviter']);
|
||||
await handleGroupAddRequest(bridge, flags[0]!, approve, '');
|
||||
expect(events).toEqual([expect.objectContaining({ flag: 'invite:999:u_inviter' })]);
|
||||
await handleGroupAddRequest(bridge, events[0]!.flag, approve, '');
|
||||
const approval = send.mock.calls.find(([cmd]) => cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'))!;
|
||||
expect(approval[0]).toBe(`OidbSvcTrpcTcp.0x10c8_${filtered ? 2 : 1}`);
|
||||
const wire = protobuf_decode<OidbBase<OidbGroupRequestAction>>(approval[1]);
|
||||
expect(wire.body).toMatchObject({
|
||||
accept: approve ? 1 : 2,
|
||||
body: { sequence: 42n, groupUin: 999, eventType: 10, message: ' ', operateTransInfo },
|
||||
body: { sequence: 42n, groupUin: 999, eventType: 2, message: ' ', operateTransInfo },
|
||||
});
|
||||
expect(
|
||||
await bridge.apis.contacts.resolveGroupJoinRequest(
|
||||
@@ -112,7 +193,7 @@ describe('non-friend group invitations', () => {
|
||||
'invite',
|
||||
'u_self',
|
||||
),
|
||||
).toMatchObject({ notifyType: 2, eventType: 10 });
|
||||
).toMatchObject({ notifyType: 1, eventType: 2 });
|
||||
});
|
||||
|
||||
it('lists the inviter and returns a flag that can approve the same invitation', async () => {
|
||||
@@ -124,21 +205,38 @@ describe('non-friend group invitations', () => {
|
||||
requester_uin: 456,
|
||||
requester_nick: 'inviter',
|
||||
checked: false,
|
||||
flag: 'slreq:1:42:999:10:0',
|
||||
flag: 'slreq:1:42:999:2:0',
|
||||
}),
|
||||
]);
|
||||
await handleGroupAddRequest(bridge, String(rows[0]!.flag), true, '');
|
||||
const approval = send.mock.calls.find(([cmd]) => cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'))!;
|
||||
const wire = protobuf_decode<OidbBase<OidbGroupRequestAction>>(approval[1]);
|
||||
expect(wire.body?.body).toMatchObject({ eventType: 10, operateTransInfo });
|
||||
expect(wire.body?.body).toMatchObject({ eventType: 2, operateTransInfo });
|
||||
});
|
||||
|
||||
it.each([{ targetUid: 'u_other' }, { state: 2 }])(
|
||||
'rejects a mismatched or processed invitation: %j',
|
||||
it('corrects the type in an older invitation flag from the current inbox', async () => {
|
||||
const { bridge, send, operateTransInfo } = setup(true);
|
||||
await handleGroupAddRequest(bridge, 'slreq:1:42:999:10:0', true, '');
|
||||
const approvals = send.mock.calls.filter(([cmd]) =>
|
||||
cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'),
|
||||
);
|
||||
expect(approvals).toHaveLength(1);
|
||||
const [cmd, bytes] = approvals[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0x10c8_2');
|
||||
expect(protobuf_decode<OidbBase<OidbGroupRequestAction>>(bytes).body?.body).toMatchObject({
|
||||
sequence: 42n,
|
||||
groupUin: 999,
|
||||
eventType: 2,
|
||||
operateTransInfo,
|
||||
});
|
||||
});
|
||||
|
||||
it.each([{ target: { uid: 'u_other' } }, { state: 2 }, { eventType: 10 }])(
|
||||
'requires a pending invitation to this account: %j',
|
||||
async (overrides) => {
|
||||
const { bridge, send, flags, notice } = setup(false, overrides);
|
||||
const { bridge, send, events, notice } = setup(false, overrides);
|
||||
await notice();
|
||||
await expect(handleGroupAddRequest(bridge, flags[0]!, true, '')).rejects.toThrow(
|
||||
await expect(handleGroupAddRequest(bridge, events[0]!.flag, true, '')).rejects.toThrow(
|
||||
'matching group request not found',
|
||||
);
|
||||
expect(send.mock.calls.some(([cmd]) => cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'))).toBe(
|
||||
@@ -147,3 +245,56 @@ describe('non-friend group invitations', () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
describe('invitations awaiting administrator approval', () => {
|
||||
it('keeps the applicant, inviter and approval type through the real codecs', async () => {
|
||||
const { bridge, send, events, notice, operateTransInfo } = setup(true, {
|
||||
eventType: 22,
|
||||
target: { uid: 'u_applicant', name: 'applicant' },
|
||||
comment: 'invited to join',
|
||||
operateTransInfo: Uint8Array.from([8, 42, 16, 231, 7, 24, 22]),
|
||||
});
|
||||
bridge.identity.rememberRequestIdentity({ groupId: 999, uid: 'u_applicant', uin: 123 });
|
||||
await notice(
|
||||
525,
|
||||
protobuf_encode<GroupInvitation>({
|
||||
cmd: 87,
|
||||
info: {
|
||||
inner: { groupUin: 999, invitorUid: 'u_inviter', targetUid: 'u_applicant' },
|
||||
},
|
||||
}),
|
||||
);
|
||||
expect(events).toEqual([
|
||||
expect.objectContaining({
|
||||
subType: 'invite',
|
||||
fromUin: 456,
|
||||
invitedUin: 123,
|
||||
flag: 'slreq:1:42:999:22:1',
|
||||
}),
|
||||
]);
|
||||
expect(await getGroupSystemMessages(bridge)).toEqual([
|
||||
expect.objectContaining({
|
||||
requester_uin: 123,
|
||||
invitor_uin: 456,
|
||||
flag: events[0]!.flag,
|
||||
}),
|
||||
]);
|
||||
await handleGroupAddRequest(bridge, events[0]!.flag, false, 'declined');
|
||||
const approvals = send.mock.calls.filter(([cmd]) =>
|
||||
cmd.startsWith('OidbSvcTrpcTcp.0x10c8_'),
|
||||
);
|
||||
expect(approvals).toHaveLength(1);
|
||||
const [cmd, bytes] = approvals[0]!;
|
||||
expect(cmd).toBe('OidbSvcTrpcTcp.0x10c8_2');
|
||||
expect(protobuf_decode<OidbBase<OidbGroupRequestAction>>(bytes).body).toMatchObject({
|
||||
accept: 2,
|
||||
body: {
|
||||
sequence: 42n,
|
||||
groupUin: 999,
|
||||
eventType: 22,
|
||||
message: 'declined',
|
||||
operateTransInfo,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -58,7 +58,7 @@ function fakeRequest(overrides: Partial<GroupRequestInfo> = {}): GroupRequestInf
|
||||
operatorName: 'op',
|
||||
sequence: 42,
|
||||
state: 1,
|
||||
eventType: 7,
|
||||
eventType: 2,
|
||||
comment: 'pls',
|
||||
filtered: false,
|
||||
...overrides,
|
||||
@@ -118,7 +118,7 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
fakeRequest({
|
||||
groupId: 999,
|
||||
sequence: 261237407,
|
||||
eventType: 7,
|
||||
eventType: 1,
|
||||
filtered: false,
|
||||
}),
|
||||
],
|
||||
@@ -131,7 +131,7 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
expect(setAddRequest).toHaveBeenCalledWith(
|
||||
999,
|
||||
261237407,
|
||||
7,
|
||||
1,
|
||||
false,
|
||||
'no',
|
||||
false,
|
||||
@@ -172,11 +172,12 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
it('matches add requests by groupId and targetUid', async () => {
|
||||
const setAddRequest = vi.fn(async () => {});
|
||||
const fetchGroupRequestsByUid = vi.fn(async () => [
|
||||
fakeRequest({ sequence: 41, targetUid: 'u_t', eventType: 2 }),
|
||||
fakeRequest({
|
||||
groupId: 999,
|
||||
targetUid: 'u_t',
|
||||
sequence: 42,
|
||||
eventType: 7,
|
||||
eventType: 1,
|
||||
filtered: false,
|
||||
}),
|
||||
]);
|
||||
@@ -188,7 +189,7 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
await handleGroupAddRequest(bridge, 'add:999:u_t', true, 'ok');
|
||||
|
||||
expect(setAddRequest).toHaveBeenCalledOnce();
|
||||
expect(setAddRequest).toHaveBeenCalledWith(999, 42, 7, true, 'ok', false, undefined);
|
||||
expect(setAddRequest).toHaveBeenCalledWith(999, 42, 1, true, 'ok', false, undefined);
|
||||
expect(fetchGroupRequestsByUid).toHaveBeenCalledWith(false, 100);
|
||||
expect(fetchGroupRequestsByUid).toHaveBeenCalledWith(true, 100);
|
||||
});
|
||||
@@ -197,11 +198,12 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
const setAddRequest = vi.fn(async () => {});
|
||||
const bridge = fakeBridge({
|
||||
fetchGroupRequestsByUid: vi.fn(async () => [
|
||||
fakeRequest({ sequence: 96, invitorUid: 'u_i', eventType: 1 }),
|
||||
fakeRequest({
|
||||
groupId: 999,
|
||||
invitorUid: 'u_i',
|
||||
sequence: 97,
|
||||
eventType: 8,
|
||||
eventType: 22,
|
||||
filtered: false,
|
||||
}),
|
||||
]),
|
||||
@@ -212,7 +214,7 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
await handleGroupAddRequest(bridge, 'invite:999:u_i', false, 'no');
|
||||
|
||||
expect(setAddRequest).toHaveBeenCalledOnce();
|
||||
expect(setAddRequest).toHaveBeenCalledWith(999, 97, 8, false, 'no', false, undefined);
|
||||
expect(setAddRequest).toHaveBeenCalledWith(999, 97, 22, false, 'no', false, undefined);
|
||||
});
|
||||
|
||||
it('finds a request that only lives in the filtered inbox (#197)', async () => {
|
||||
@@ -284,7 +286,7 @@ describe('onebot/modules/request-actions / handleGroupAddRequest', () => {
|
||||
expect(setAddRequest).toHaveBeenCalledExactlyOnceWith(
|
||||
999,
|
||||
124,
|
||||
7,
|
||||
2,
|
||||
true,
|
||||
'',
|
||||
false,
|
||||
|
||||
Reference in new issue
Block a user