Add MediaCache and media segment sink

Introduce an in-memory MediaCache to index recently seen image and record segments and wire a MediaSegmentSink into EventConverter to populate it. OneBotInstance now constructs MediaCache and registers a sink to remember image/record metadata; instance-context exposes get_image/get_record lookup handlers that consult the cache (and re-resolve record URLs via bridge OIDB when needed). ApiHandler actions get_image/get_record now accept file_id fallback and use the new context lookups. Removed the old findMediaInStore stub and added comprehensive tests for the cache and sink behavior.
This commit is contained in:
手瓜一十雪 committed 2026-05-09 15:33:13 +08:00
1 parent e53a8a01b7
commit 1565749105
7 files changed
+509 -43

No files matched your search

+3
View File
@@ -105,6 +105,9 @@ export interface ApiActionContext {
getCookiesStr?: (domain: string) => Promise<string>;
getCsrfToken?: () => Promise<number>;
getCredentials?: (domain: string) => Promise<{ cookies: string; token: number; csrf_token: number }>;
// Media lookup (populated from previously dispatched message segments)
getImageInfo?: (file: string) => Promise<JsonObject | null>;
getRecordInfo?: (file: string) => Promise<JsonObject | null>;
}
type ActionHandler = (params: JsonObject) => Promise<import('./types').ApiResponse>;