Filter out invalid images from peertube
This commit is contained in:
parent
3299c9e124
commit
5800f354cc
1 changed files with 21 additions and 19 deletions
|
@ -35,31 +35,33 @@ function getImagesInfoFromObject (actorObject: ActivityPubActor, type: ActorImag
|
||||||
? actorObject.icons || actorObject.icon
|
? actorObject.icons || actorObject.icon
|
||||||
: actorObject.image
|
: actorObject.image
|
||||||
|
|
||||||
return normalizeIconOrImage(iconsOrImages).map(iconOrImage => {
|
return normalizeIconOrImage(iconsOrImages)
|
||||||
const mimetypes = MIMETYPES.IMAGE
|
.map(iconOrImage => {
|
||||||
|
const mimetypes = MIMETYPES.IMAGE
|
||||||
|
|
||||||
if (iconOrImage.type !== 'Image' || !isActivityPubUrlValid(iconOrImage.url)) return undefined
|
if (iconOrImage.type !== 'Image' || !isActivityPubUrlValid(iconOrImage.url)) return undefined
|
||||||
|
|
||||||
let extension: string
|
let extension: string
|
||||||
|
|
||||||
if (iconOrImage.mediaType) {
|
if (iconOrImage.mediaType) {
|
||||||
extension = mimetypes.MIMETYPE_EXT[iconOrImage.mediaType]
|
extension = mimetypes.MIMETYPE_EXT[iconOrImage.mediaType]
|
||||||
} else {
|
} else {
|
||||||
const tmp = getLowercaseExtension(iconOrImage.url)
|
const tmp = getLowercaseExtension(iconOrImage.url)
|
||||||
|
|
||||||
if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp
|
if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!extension) return undefined
|
if (!extension) return undefined
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: buildUUID() + extension,
|
name: buildUUID() + extension,
|
||||||
fileUrl: iconOrImage.url,
|
fileUrl: iconOrImage.url,
|
||||||
height: iconOrImage.height,
|
height: iconOrImage.height,
|
||||||
width: iconOrImage.width,
|
width: iconOrImage.width,
|
||||||
type
|
type
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.filter(i => !!i)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActorDisplayNameFromObject (actorObject: ActivityPubActor) {
|
function getActorDisplayNameFromObject (actorObject: ActivityPubActor) {
|
||||||
|
|
Loading…
Reference in a new issue