Add BridgeEventBus and network manager
Introduce a typed per-kind BridgeEventBus and migrate away from the legacy single-callback firehose. Bridge now exposes `events` and emits via the bus; BridgeManager/OneBotManager no longer wire a global event callback. Add a focused onebot event pipeline (event-pipeline.ts) that subscribes per-kind handlers on instance construction. Replace the in-memory MediaCache with a persistent MediaStore and update all lookups accordingly. Replace the old Http/Ws/HttpPost transport implementations with a unified OneBotNetworkManager and pluggable adapters (server/client/post), and update OneBotInstance to install and manage adapters from config. Remove several legacy files (http-transport, http-post-transport, ws-transport, media-cache) and update imports across the codebase. Also add tests for the bridge event bus, event pipeline, network manager, and rename media tests to reflect MediaStore usage. The bus dispatches handlers in parallel and reports handler errors via an onError hook to avoid one faulty listener blocking others.
This commit is contained in:
1 parent
1565749105
commit
144e0fdd59
27 files changed
+2357
-1234
No files matched your search
@@ -396,9 +396,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
if (!file) return failedResponse(RETCODE.BAD_REQUEST, 'file is required');
|
||||
if (!ctx.getImageInfo) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||
const info = await ctx.getImageInfo(file);
|
||||
if (info) {
|
||||
return okResponse(info as unknown as import('../types').JsonValue);
|
||||
}
|
||||
if (info) return okResponse(info);
|
||||
return failedResponse(RETCODE.ACTION_FAILED, 'image not found in cache');
|
||||
});
|
||||
|
||||
@@ -407,9 +405,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
if (!file) return failedResponse(RETCODE.BAD_REQUEST, 'file is required');
|
||||
if (!ctx.getRecordInfo) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||
const info = await ctx.getRecordInfo(file);
|
||||
if (info) {
|
||||
return okResponse(info as unknown as import('../types').JsonValue);
|
||||
}
|
||||
if (info) return okResponse(info);
|
||||
return failedResponse(RETCODE.ACTION_FAILED, 'record not found in cache');
|
||||
});
|
||||
|
||||
@@ -465,7 +461,7 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
||||
const context = params.context as import('../types').JsonObject | undefined;
|
||||
const operation = params.operation as Record<string, unknown> | undefined;
|
||||
if (!context || !operation) return failedResponse(RETCODE.BAD_REQUEST, 'context and operation are required');
|
||||
const { executeQuickOperation } = await import('../http-post-transport');
|
||||
const { executeQuickOperation } = await import('../network/quick-operation');
|
||||
await executeQuickOperation(context, operation, h);
|
||||
return okResponse();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user