fix(core): restore group remarks in queries

Request and retain the group remark information needed by group list and group detail queries while preserving the existing safeguards for large rosters.

Synchronize confirmed group remark changes with the local identity roster and persistent cache. Remote failures leave local state untouched, and missing roster entries remain observable without creating phantom groups.

Add regression coverage for query mapping, request scope, persistence, failed updates, unknown groups, and closed identity stores.

Fixes #304
This commit is contained in:
DrSmoothl committed 2026-08-01 21:11:02 +08:00
1 parent 6372e1479c
commit fb4d7716a1
10 files changed
+173 -10

No files matched your search

@@ -2,16 +2,20 @@
// the bot sees this — the group's actual name is untouched).
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
import { createLogger } from '@snowluma/common/logger';
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
import type { Oidb0xf16Req } from '@snowluma/proto-defs/oidb-actions/base';
import { invokeOidb, type OidbSender } from '../../oidb-service';
import type { BridgeContext } from '../../bridge-context';
const log = createLogger('Bridge.GroupAdmin');
export namespace SetGroupRemark {
export const command = 0xF16;
export const subCommand = 1;
export interface Params { groupId: number; remark: string; }
export type Deps = OidbSender;
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
export const serialize = (_ctx: Deps, p: Params): Oidb0xf16Req => ({
inner: { groupId: BigInt(p.groupId), remark: p.remark },
@@ -24,6 +28,28 @@ export namespace SetGroupRemark {
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
export const invoke = (deps: Deps, params: Params): Promise<void> =>
invokeOidb(deps, SetGroupRemark, params);
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
await invokeOidb(deps, SetGroupRemark, params);
// QQ has already accepted the mutation. Keep the local roster coherent,
// but never turn a local-cache problem into a false remote failure that
// encourages callers to repeat the mutation.
try {
const updated = deps.identity.updateGroupRemark(params.groupId, params.remark);
if (!updated) {
log.warn(
'local group roster did not contain server-confirmed remark target: uin=%s group=%d',
deps.identity.uin,
params.groupId,
);
}
} catch (error: unknown) {
log.error(
'local identity synchronization failed after confirmed group remark update: uin=%s group=%d: %s',
deps.identity.uin,
params.groupId,
error instanceof Error ? error.message : String(error),
);
}
};
}