feat(onebot): report the invited account on group invite events
request.group.invite already identified the inviter. The event now also reports the invited account when QQ provides it. Closes #394
This commit is contained in:
12 files changed
+181
-3
No files matched your search
@@ -16,11 +16,13 @@ export function convertFriendRequest(ctx: ConverterContext, event: FriendRequest
|
||||
}
|
||||
|
||||
export function convertGroupInvite(ctx: ConverterContext, event: GroupInvite): JsonObject {
|
||||
const invitedId = event.invitedUin ?? 0;
|
||||
return request(ctx, event, {
|
||||
request_type: 'group',
|
||||
sub_type: event.subType || 'invite',
|
||||
group_id: event.groupId,
|
||||
user_id: event.fromUin,
|
||||
...(invitedId > 0 ? { invited_id: invitedId } : {}),
|
||||
comment: event.message,
|
||||
flag: event.flag,
|
||||
});
|
||||
|
||||
@@ -180,6 +180,10 @@ export class GroupRequestPoller {
|
||||
groupId: request.groupId,
|
||||
fromUin,
|
||||
fromUid,
|
||||
...(notifyType === 1 ? {
|
||||
invitedUin: request.targetUin,
|
||||
invitedUid: request.targetUid,
|
||||
} : {}),
|
||||
subType,
|
||||
message: request.comment,
|
||||
flag: formatGroupRequestFlag(inviteCardSequence === undefined ? request : {
|
||||
|
||||
@@ -363,6 +363,23 @@ describe('convertEvent — request kinds', () => {
|
||||
} as QQEventVariant);
|
||||
expect(withSubType!.sub_type).toBe('add');
|
||||
});
|
||||
|
||||
it('group_invite: reports the invitee without replacing user_id (#394)', async () => {
|
||||
const out = await convertEvent(bareCtx(), {
|
||||
kind: 'group_invite', time: 1, selfUin: SELF_ID, groupId: GROUP_ID,
|
||||
fromUin: PEER_UIN, invitedUin: 4242, message: '', flag: 'gflag', subType: 'invite',
|
||||
} as QQEventVariant);
|
||||
expect(out!.user_id).toBe(PEER_UIN);
|
||||
expect(out!.invited_id).toBe(4242);
|
||||
});
|
||||
|
||||
it('group_invite: omits invited_id when the invitee is unknown', async () => {
|
||||
const out = await convertEvent(bareCtx(), {
|
||||
kind: 'group_invite', time: 1, selfUin: SELF_ID, groupId: GROUP_ID,
|
||||
fromUin: PEER_UIN, message: '', flag: 'gflag', subType: 'invite',
|
||||
} as QQEventVariant);
|
||||
expect(out).not.toHaveProperty('invited_id');
|
||||
});
|
||||
});
|
||||
|
||||
describe('convertEvent — message elements', () => {
|
||||
|
||||
@@ -63,6 +63,8 @@ describe('GroupRequestPoller', () => {
|
||||
groupId: 999,
|
||||
fromUin: 456,
|
||||
fromUid: 'inviter_uid',
|
||||
invitedUin: 123,
|
||||
invitedUid: 'target_uid',
|
||||
subType: 'invite',
|
||||
message: 'please',
|
||||
flag: 'slreq:1:42:999:2:0',
|
||||
|
||||
Reference in new issue
Block a user