fix(onebot): allow typecheck of media cache field folding

The persist helper assigned through a generic object type, which
TypeScript rejects. Write the sanitized copy on a plain record.
This commit is contained in:
DrSmoothl committed 2026-09-18 00:19:18 +08:00
1 parent ce050d1ba1
commit 20c31e11a8
1 file changed
+2 -2
+2 -2
View File
@@ -298,8 +298,8 @@ function foldMediaKey(value: string): string {
return `inline:${createHash('sha256').update(value).digest('hex')}`;
}
function persistableMediaInfo<T extends object>(info: T): T {
const next = { ...info } as T & Record<string, unknown>;
function persistableMediaInfo(info: object): Record<string, unknown> {
const next: Record<string, unknown> = { ...info };
for (const field of ['file', 'fileId', 'fileName'] as const) {
const value = next[field];
if (typeof value === 'string') next[field] = foldMediaKey(value);