Skip to content

Node.js based forum software built for the modern web

fix: handling of empty custom user fields from remote users

Julian Lam1bebb82b036f
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js
index 68e5c0210f..5006d24fe4 100644
--- a/src/activitypub/mocks.js
+++ b/src/activitypub/mocks.js
@@ -69,9 +69,10 @@ Mocks.profile = async (actors, hostMap) => {
bgColor = iconBackgrounds[bgColor % iconBackgrounds.length];
// Add custom fields into user hash
- const customFields = actor.attachment ? actor.attachment
- .filter(attachment => attachment.type === 'PropertyValue')
- .reduce((map, { name, value }) => map.set(name, value), new Map()) :
+ const customFields = actor.attachment && Array.isArray(actor.attachment) && actor.attachment.length ?
+ actor.attachment
+ .filter(attachment => attachment.type === 'PropertyValue')
+ .reduce((map, { name, value }) => map.set(name, value), new Map()) :
undefined;
const payload = {