fix(friend): align remark and delete protocols
Route friend remark updates and clears through the commands used by current QQ clients. Emit the required delete flags and surface post-delete cache refresh failures. Add byte-exact regression coverage for all affected requests. Fixes #284.
This commit is contained in:
9 files changed
+192
-54
No files matched your search
@@ -0,0 +1,35 @@
|
||||
// 0x912F_0 — clear the remark (备注) stored for a friend. Current QQ
|
||||
// uses a separate StrangerRemarkSetWorker command instead of sending an
|
||||
// empty string through 0x912E_0.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbClearFriendRemark } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace ClearFriendRemark {
|
||||
export const command = 0x912F;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params {
|
||||
userId: number;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = async (ctx: Deps, p: Params): Promise<OidbClearFriendRemark> => ({
|
||||
target: { targetUid: await ctx.resolveUserUid(p.userId) },
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<OidbClearFriendRemark>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbClearFriendRemark>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, ClearFriendRemark, params);
|
||||
}
|
||||
@@ -35,8 +35,9 @@ export namespace DeleteFriend {
|
||||
field2: 109,
|
||||
field3: { field1: 8, field2: 8, field3: 50 },
|
||||
},
|
||||
// DelBuddyWorker receives both booleans explicitly from current QQ.
|
||||
block: p.block ?? false,
|
||||
field4: false,
|
||||
field4: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// 0xB6E_2 — set the remark (备注) shown for a friend in the bot's
|
||||
// own roster. Doesn't affect what the friend sees.
|
||||
// 0x912E_0 — set the remark (备注) shown for a friend in the bot's
|
||||
// own roster. Current QQ routes ordinary friend remarks through
|
||||
// StrangerRemarkSetWorker with scene=0.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
@@ -8,8 +9,8 @@ import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace SetFriendRemark {
|
||||
export const command = 0xB6E;
|
||||
export const subCommand = 2;
|
||||
export const command = 0x912E;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params {
|
||||
userId: number;
|
||||
@@ -19,8 +20,11 @@ export namespace SetFriendRemark {
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = async (ctx: Deps, p: Params): Promise<OidbSetFriendRemark> => ({
|
||||
targetUid: await ctx.resolveUserUid(p.userId),
|
||||
remark: p.remark,
|
||||
change: {
|
||||
target: { targetUid: await ctx.resolveUserUid(p.userId) },
|
||||
remark: p.remark,
|
||||
},
|
||||
scene: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_ctx: Deps, _: OidbEmpty): void => {};
|
||||
|
||||
Reference in new issue
Block a user