Fix remote avatar without AP mediatype field
This commit is contained in:
parent
30ff193a60
commit
c6de3a85ee
|
@ -422,7 +422,8 @@ const MIMETYPES = {
|
||||||
'image/png': '.png',
|
'image/png': '.png',
|
||||||
'image/jpg': '.jpg',
|
'image/jpg': '.jpg',
|
||||||
'image/jpeg': '.jpg'
|
'image/jpeg': '.jpg'
|
||||||
}
|
},
|
||||||
|
EXT_MIMETYPE: null as { [ id: string ]: string }
|
||||||
},
|
},
|
||||||
VIDEO_CAPTIONS: {
|
VIDEO_CAPTIONS: {
|
||||||
MIMETYPE_EXT: {
|
MIMETYPE_EXT: {
|
||||||
|
@ -438,6 +439,7 @@ const MIMETYPES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT)
|
MIMETYPES.AUDIO.EXT_MIMETYPE = invert(MIMETYPES.AUDIO.MIMETYPE_EXT)
|
||||||
|
MIMETYPES.IMAGE.EXT_MIMETYPE = invert(MIMETYPES.IMAGE.MIMETYPE_EXT)
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ import {
|
||||||
MActorId,
|
MActorId,
|
||||||
MChannel
|
MChannel
|
||||||
} from '../../typings/models'
|
} from '../../typings/models'
|
||||||
|
import { extname } from 'path'
|
||||||
|
|
||||||
// Set account keys, this could be long so process after the account creation and do not block the client
|
// Set account keys, this could be long so process after the account creation and do not block the client
|
||||||
function setAsyncActorKeys <T extends MActor> (actor: T) {
|
function setAsyncActorKeys <T extends MActor> (actor: T) {
|
||||||
|
@ -215,19 +216,21 @@ async function fetchActorTotalItems (url: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAvatarInfoIfExists (actorJSON: ActivityPubActor) {
|
function getAvatarInfoIfExists (actorJSON: ActivityPubActor) {
|
||||||
if (
|
const mimetypes = MIMETYPES.IMAGE
|
||||||
actorJSON.icon && actorJSON.icon.type === 'Image' && MIMETYPES.IMAGE.MIMETYPE_EXT[actorJSON.icon.mediaType] !== undefined &&
|
const icon = actorJSON.icon
|
||||||
isActivityPubUrlValid(actorJSON.icon.url)
|
|
||||||
) {
|
|
||||||
const extension = MIMETYPES.IMAGE.MIMETYPE_EXT[actorJSON.icon.mediaType]
|
|
||||||
|
|
||||||
return {
|
if (!icon || icon.type !== 'Image' || !isActivityPubUrlValid(icon.url)) return undefined
|
||||||
name: uuidv4() + extension,
|
|
||||||
fileUrl: actorJSON.icon.url
|
const extension = icon.mediaType
|
||||||
}
|
? mimetypes.MIMETYPE_EXT[icon.mediaType]
|
||||||
|
: extname(icon.url)
|
||||||
|
|
||||||
|
if (!extension) return undefined
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: uuidv4() + extension,
|
||||||
|
fileUrl: icon.url
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) {
|
async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) {
|
||||||
|
|
Loading…
Reference in New Issue