fix(core): resolve self uid instead of shipping an empty one (forward/flash)

阶段 2:修 self-uid 收口暴露的 2 处静默空串 bug。warmup 未完成时 identity.selfUid
为 null,原 `?? ''` 会把空 uid 放进出网包:

- forward.ts:154 responseHead.toUid(转发广播消息坏包)
- flash-transfer.ts:279 fileset uploader.uid(空 uid 会被服务端 drop fileset)

均改为 `await resolveSelfUid(...)`:正常路径(selfUid 有值,几乎总是)命中缓存、取值
完全不变;仅在身份未就绪的极端情况从「静默发坏包」变成「明确报错」(fail-loud)。
两处外层函数本就 async。group-admin.ts:64 的 ?? '' 是合成本地事件、best-effort、
非出网,保留不动。

core 471 全绿、typecheck 干净;对抗性 Agent 确认正常路径不变、无测试回归。
This commit is contained in:
DrSmoothl committed 2026-07-01 19:18:10 +08:00
1 parent 3db89d0bd0
commit f111ba7129
2 files changed
+7 -2

No files matched your search

@@ -2,6 +2,7 @@
// 复用 OIDB 基础设施(invokeOidb),协议层在 @snowluma/protocol/oidb-services/flash-transfer/。
import type { BridgeContext } from '../bridge-context';
import { resolveSelfUid } from './shared';
import type { FlashFileEntry } from '@snowluma/proto-defs/oidb-actions/flash-transfer';
import { GetFilesetDetail } from '@snowluma/protocol/oidb-services/flash-transfer/get-fileset-detail';
import { ListFilesets } from '@snowluma/protocol/oidb-services/flash-transfer/list-filesets';
@@ -276,7 +277,9 @@ export class FlashTransferApi {
const uploader = {
uin: this.ctx.identity.uin,
nickname: this.ctx.identity.nickname,
uid: this.ctx.identity.selfUid ?? '',
// Resolve our own uid rather than ship an empty one — a blank uploader
// uid drops the fileset if this runs before warmup populated selfUid.
uid: await resolveSelfUid(this.ctx),
};
// 读取所有文件,每个分配 fileUuid + 序号 + formatCode
const items: { bytes: Uint8Array; fileName: string; fileUuid: string; fileIndex: number; formatCode: number }[] = [];
+3 -1
View File
@@ -151,7 +151,9 @@ async function buildForwardPushBody(
return {
responseHead: {
fromUin,
toUid: bridge.identity.selfUid ?? '',
// Resolve our own uid rather than ship an empty one — a blank toUid is a
// broken packet if this runs before warmup populated selfUid.
toUid: await resolveSelfUid(bridge),
forward: {
friendName: nickname,
},