fix(onebot): report rejected group kick operations
Treat group member removal as successful only when QQ accepts the operation. Preserve the rejection reason so callers no longer receive a false success when a target cannot be removed. Apply the same behavior to single-member and batch removal actions, while keeping accepted operations unchanged. Add regression coverage for both successful and rejected responses. Fixes #298
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
// namespace because proton needs distinct types per call site.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbKickMember } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
OidbKickMember,
|
||||
OidbKickMemberResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
@@ -29,13 +32,17 @@ export namespace KickMember {
|
||||
reason: p.reason ?? '',
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
|
||||
export const deserialize = (_ctx: Deps, body: OidbKickMemberResponse): void => {
|
||||
if (body.errorMsg) {
|
||||
throw new Error(`kick member failed: ${body.errorMsg}`);
|
||||
}
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<OidbKickMember>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbKickMember>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbKickMemberResponse> =>
|
||||
protobuf_decode<OidbBase<OidbKickMemberResponse>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, KickMember, params);
|
||||
|
||||
@@ -3,8 +3,11 @@
|
||||
// namespace so proton can monomorphize independently.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0x8a0Req } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
Oidb0x8a0Req,
|
||||
OidbKickMemberResponse,
|
||||
} from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
@@ -28,13 +31,17 @@ export namespace KickMembers {
|
||||
field12: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
|
||||
export const deserialize = (_ctx: Deps, body: OidbKickMemberResponse): void => {
|
||||
if (body.errorMsg) {
|
||||
throw new Error(`kick members failed: ${body.errorMsg}`);
|
||||
}
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<Oidb0x8a0Req>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0x8a0Req>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbKickMemberResponse> =>
|
||||
protobuf_decode<OidbBase<OidbKickMemberResponse>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, KickMembers, params);
|
||||
|
||||
Reference in New Issue
Block a user