Normalize attachment MIME types from filenames, hydrate playable media and gallery tiles from disk without redundant peer requests, reset stalled partial downloads, and improve gallery retry/hydration UX across chat and DMs. Co-authored-by: Cursor <cursoragent@cursor.com>
18 lines
491 B
TypeScript
18 lines
491 B
TypeScript
import { isImageAttachment } from './attachment-image.rules';
|
|
import { resolveAttachmentMime } from './attachment-mime.rules';
|
|
import type { AttachmentMeta } from '../models/attachment.model';
|
|
|
|
export function normalizeAttachmentMeta<T extends AttachmentMeta>(meta: T): T {
|
|
const mime = resolveAttachmentMime(meta.filename, meta.mime);
|
|
|
|
return {
|
|
...meta,
|
|
mime,
|
|
isImage: isImageAttachment({
|
|
filename: meta.filename,
|
|
isImage: meta.isImage,
|
|
mime
|
|
})
|
|
};
|
|
}
|