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:
1 file changed
+2
-2
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user