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 })
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