fix(onebot): restore group join request delivery

Refs #658
This commit is contained in:
DrSmoothl committed 2026-11-06 22:49:52 +08:00
1 parent b0612d8d12
commit 43b63e9a75
11 files changed
+315 -176

No files matched your search

@@ -19,45 +19,31 @@ import type {
import type { OidbGroupRequestList } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
// Current QQ's EncodeOperateSysNotify maps the high-level list notification
// type to the discriminator sent by 0x10C8. This table was read directly from
// the current Linux client; keeping the distinction prevents list type 7
// (join request) from being incorrectly sent back as operation type 7.
const GROUP_REQUEST_OPERATION_TYPE = new Map<number, number>([
// Field 2 in a list entry and in its approval uses the same wire value.
// Only the client-facing notification type needs translation.
const GROUP_REQUEST_NOTIFY_TYPES = new Map<number, number>([
[0, 0],
[1, 2],
[2, 10],
[3, 11],
[4, 12],
[5, 22],
[6, 35],
[7, 1],
[8, 3],
[9, 6],
[10, 7],
[11, 13],
[12, 15],
[13, 16],
[14, 17],
[15, 19],
[16, 8],
[17, 100],
[1, 7],
[2, 1],
[3, 8],
[6, 9],
[7, 10],
[8, 16],
[10, 2],
[11, 3],
[12, 4],
[13, 11],
[15, 12],
[16, 13],
[17, 14],
[19, 15],
[22, 5],
[35, 6],
[100, 17],
]);
const GROUP_REQUEST_OPERATION_OUTPUT = new Set(GROUP_REQUEST_OPERATION_TYPE.values());
export function groupRequestOperationType(notifyType: number): number | null {
const mapped = GROUP_REQUEST_OPERATION_TYPE.get(notifyType);
if (mapped !== undefined) {
return mapped;
}
// Some list replies already carry the mapped discriminator (e.g. 22).
if (GROUP_REQUEST_OPERATION_OUTPUT.has(notifyType)) {
return notifyType;
}
return null;
export function groupRequestNotifyType(eventType: number): number | undefined {
return GROUP_REQUEST_NOTIFY_TYPES.get(eventType);
}
export interface DecodedGroupRequestUser {
+19 -5
View File
@@ -152,19 +152,33 @@ export interface GroupRequestInfo {
operatorName: string;
sequence: number;
state: number;
/** High-level notification type returned by the request list. */
/** Client notification type corresponding to the wire discriminator, when known. */
notifyType?: number;
/** 0x10C8 operation discriminator derived from notifyType. */
/** Wire discriminator shared by the request list and approval. */
eventType: number;
comment: string;
filtered: boolean;
operateTransInfo?: Uint8Array;
}
/** Invitations handled by the invited account, rather than a group administrator.
* Notification types 1 and 2 use different approval discriminators. */
/** A member invited the account to join. Wire type 10 reports a refused invitation. */
export function isSelfGroupInvitation(request: Pick<GroupRequestInfo, 'eventType'>): boolean {
return request.eventType === 2 || request.eventType === 10;
return request.eventType === 2;
}
/** Only joins and invitations correspond to a OneBot group request. */
export function groupRequestSubType(
request: Pick<GroupRequestInfo, 'eventType'>,
): 'add' | 'invite' | undefined {
if (request.eventType === 1) {
return 'add';
}
if (isSelfGroupInvitation(request) || request.eventType === 22) {
return 'invite';
}
return undefined;
}
/** Approval tuple required by OIDB 0x10C8. The OneBot flag is opaque to