aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-02-12 10:23:24 +0100
committerChocobozzz <me@florianbigard.com>2020-02-12 10:23:24 +0100
commitc6de3a85eebbdef3029769ea6225277419ffbe00 (patch)
tree749d600a294567949e305e3269e4fb97fb054e0b /server/lib/activitypub
parent30ff193a60487cffd5f2d2316d11ac88f5a7e7fd (diff)
downloadPeerTube-c6de3a85eebbdef3029769ea6225277419ffbe00.tar.gz
PeerTube-c6de3a85eebbdef3029769ea6225277419ffbe00.tar.zst
PeerTube-c6de3a85eebbdef3029769ea6225277419ffbe00.zip
Fix remote avatar without AP mediatype field
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r--server/lib/activitypub/actor.ts27
1 files changed, 15 insertions, 12 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 3f6edc070..8c5c618fc 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -35,6 +35,7 @@ import {
35 MActorId, 35 MActorId,
36 MChannel 36 MChannel
37} from '../../typings/models' 37} from '../../typings/models'
38import { extname } from 'path'
38 39
39// Set account keys, this could be long so process after the account creation and do not block the client 40// Set account keys, this could be long so process after the account creation and do not block the client
40function setAsyncActorKeys <T extends MActor> (actor: T) { 41function setAsyncActorKeys <T extends MActor> (actor: T) {
@@ -215,19 +216,21 @@ async function fetchActorTotalItems (url: string) {
215} 216}
216 217
217function getAvatarInfoIfExists (actorJSON: ActivityPubActor) { 218function getAvatarInfoIfExists (actorJSON: ActivityPubActor) {
218 if ( 219 const mimetypes = MIMETYPES.IMAGE
219 actorJSON.icon && actorJSON.icon.type === 'Image' && MIMETYPES.IMAGE.MIMETYPE_EXT[actorJSON.icon.mediaType] !== undefined && 220 const icon = actorJSON.icon
220 isActivityPubUrlValid(actorJSON.icon.url) 221
221 ) { 222 if (!icon || icon.type !== 'Image' || !isActivityPubUrlValid(icon.url)) return undefined
222 const extension = MIMETYPES.IMAGE.MIMETYPE_EXT[actorJSON.icon.mediaType] 223
223 224 const extension = icon.mediaType
224 return { 225 ? mimetypes.MIMETYPE_EXT[icon.mediaType]
225 name: uuidv4() + extension, 226 : extname(icon.url)
226 fileUrl: actorJSON.icon.url
227 }
228 }
229 227
230 return undefined 228 if (!extension) return undefined
229
230 return {
231 name: uuidv4() + extension,
232 fileUrl: icon.url
233 }
231} 234}
232 235
233async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) { 236async function addFetchOutboxJob (actor: Pick<ActorModel, 'id' | 'outboxUrl'>) {