futu_server/body_aware_acc_id.rs
1//! v1.4.104: 此模块已搬到 [`futu_auth_pipeline::body_aware`] +
2//! [`futu_auth_pipeline::response_filter`] (跨 4 surface 共享).
3//!
4//! 本文件保留为 thin re-export shim, 兼容现有调用方
5//! (gRPC `futu-grpc/src/server.rs` / WS `futu-server/src/ws_listener.rs`).
6//! 阶段 2-5 4 surface migrate 完后, 调用方逐步切到
7//! `futu_auth_pipeline::*` 直接调用; 全部切完后此文件可删.
8//!
9//! 历史:
10//! - v1.4.103 codex F3.2 / F3.3 / F1.1 / F2.10 (P1) round 3/5: 此模块在
11//! futu-server 加, gRPC + raw WS 共用 `build_check_ctxs` /
12//! `filter_acc_list_response` 防 hand-copy diverge.
13//! - v1.4.104: 系统性重构 — 抽 futu-auth-pipeline crate, 4 surface 都依赖.
14
15// Re-export — 让旧 import path `futu_server::body_aware_acc_id::build_check_ctxs`
16// 继续工作.
17pub use futu_auth_pipeline::body_aware::build_check_ctxs;
18
19/// v1.4.104 兼容: 旧调用方 (gRPC server.rs / WS ws_listener.rs) 用
20/// `filter_acc_list_response(proto_id, body, allowed)` 直调. 新代码应该用
21/// [`futu_auth_pipeline::FilterRegistry::apply`] (单一注册表, 加新 filter 不
22///改调用方).
23///
24/// 本 wrapper 内部 lazy-init 一个全局 [`futu_auth_pipeline::FilterRegistry`]
25/// with defaults (proto 2001 = AccListFilter), 调 `apply`.
26#[must_use]
27pub fn filter_acc_list_response(
28 proto_id: u32,
29 body: &[u8],
30 allowed: Option<&std::collections::HashSet<u64>>,
31) -> Vec<u8> {
32 use std::sync::OnceLock;
33 static REGISTRY: OnceLock<futu_auth_pipeline::FilterRegistry> = OnceLock::new();
34 let reg = REGISTRY.get_or_init(futu_auth_pipeline::FilterRegistry::with_defaults);
35 reg.apply(proto_id, body.to_vec(), allowed)
36}
37
38#[cfg(test)]
39mod tests;