]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/actor.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / actor.ts
index 8c5c618fc2e8ff80125fb9e5492eac220f0c7d91..9eabef4b0b175da39173af1825a62435256f7cc8 100644 (file)
@@ -176,8 +176,8 @@ async function updateActorAvatarInstance (actor: MActorDefault, info: AvatarInfo
   if (!info.name) return actor
 
   if (actor.Avatar) {
-    // Don't update the avatar if the filename did not change
-    if (actor.Avatar.fileUrl === info.fileUrl) return actor
+    // Don't update the avatar if the file URL did not change
+    if (info.fileUrl && actor.Avatar.fileUrl === info.fileUrl) return actor
 
     try {
       await actor.Avatar.destroy({ transaction: t })
@@ -221,9 +221,15 @@ function getAvatarInfoIfExists (actorJSON: ActivityPubActor) {
 
   if (!icon || icon.type !== 'Image' || !isActivityPubUrlValid(icon.url)) return undefined
 
-  const extension = icon.mediaType
-    ? mimetypes.MIMETYPE_EXT[icon.mediaType]
-    : extname(icon.url)
+  let extension: string
+
+  if (icon.mediaType) {
+    extension = mimetypes.MIMETYPE_EXT[icon.mediaType]
+  } else {
+    const tmp = extname(icon.url)
+
+    if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp
+  }
 
   if (!extension) return undefined