Detect file type from misskey files
This commit is contained in:
parent
08102da40f
commit
96846a54c3
|
@ -126,10 +126,23 @@ namespace MisskeyAPI {
|
|||
}
|
||||
}
|
||||
|
||||
export const fileType = (s: string): 'unknown' | 'image' | 'gifv' | 'video' => {
|
||||
if (s === 'image/gif') {
|
||||
return 'gifv'
|
||||
}
|
||||
if (s.includes('image')) {
|
||||
return 'image'
|
||||
}
|
||||
if (s.includes('video')) {
|
||||
return 'video'
|
||||
}
|
||||
return 'unknown'
|
||||
}
|
||||
|
||||
export const file = (f: Entity.File): MegalodonEntity.Attachment => {
|
||||
return {
|
||||
id: f.id,
|
||||
type: 'image',
|
||||
type: fileType(f.type),
|
||||
url: f.url,
|
||||
remote_url: f.url,
|
||||
preview_url: f.thumbnailUrl,
|
||||
|
|
Loading…
Reference in a new issue