From 84c6478849dd80a25bdd749524363220c28861cc Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Mon, 10 Apr 2023 13:18:06 -0600 Subject: [PATCH] Minor fixes around images --- core/activitypub/actor.js | 3 ++- core/activitypub/util.js | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/core/activitypub/actor.js b/core/activitypub/actor.js index 16af216f..442a3c52 100644 --- a/core/activitypub/actor.js +++ b/core/activitypub/actor.js @@ -98,7 +98,8 @@ module.exports = class Actor extends ActivityPubObject { const url = userSettings[t]; if (url) { const fn = paths.basename(url); - const mt = mimeTypes.contentType(fn); + const mt = + mimeTypes.contentType(fn) || mimeTypes.contentType('dummy.png'); if (mt) { o[t] = { mediaType: mt, diff --git a/core/activitypub/util.js b/core/activitypub/util.js index 9360e937..597710dd 100644 --- a/core/activitypub/util.js +++ b/core/activitypub/util.js @@ -16,7 +16,7 @@ const fs = require('graceful-fs'); const paths = require('path'); const moment = require('moment'); const { encode, decode } = require('html-entities'); -const { isString } = require('lodash'); +const { isString, get } = require('lodash'); const { stripHtml } = require('string-strip-html'); exports.getActorId = o => o.actor?.id || o.actor; @@ -152,8 +152,8 @@ function getUserProfileTemplatedBody( OUTBOX: userAsActor.outbox, FOLLOWERS: userAsActor.followers, FOLLOWING: userAsActor.following, - USER_ICON: userAsActor.icon.url, - USER_IMAGE: userAsActor.image.url, + USER_ICON: get(userAsActor, 'icon.url', ''), + USER_IMAGE: get(userAsActor, 'image.url', ''), PREFERRED_USERNAME: userAsActor.preferredUsername, NAME: userAsActor.name, SEX: user.getProperty(UserProps.Sex),