Skip to content

Node.js based forum software built for the modern web

fix: do not include image or icon props if they are falsy values

Julian Lam603068aebb79
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js
index 1e04fb99ab..81db4b7a01 100644
--- a/src/activitypub/mocks.js
+++ b/src/activitypub/mocks.js
@@ -486,35 +486,37 @@ Mocks.actors.user = async (uid) => {
});
return {
- '@context': [
- 'https://www.w3.org/ns/activitystreams',
- 'https://w3id.org/security/v1',
- ],
- id: `${nconf.get('url')}/uid/${uid}`,
- url: `${nconf.get('url')}/user/${userslug}`,
- followers: `${nconf.get('url')}/uid/${uid}/followers`,
- following: `${nconf.get('url')}/uid/${uid}/following`,
- inbox: `${nconf.get('url')}/uid/${uid}/inbox`,
- outbox: `${nconf.get('url')}/uid/${uid}/outbox`,
-
- type: 'Person',
- name: username !== displayname ? fullname : username, // displayname is escaped, fullname is not
- preferredUsername: userslug,
- summary: aboutmeParsed,
- icon: picture,
- image: cover,
- published: new Date(joindate).toISOString(),
- attachment,
-
- publicKey: {
- id: `${nconf.get('url')}/uid/${uid}#key`,
- owner: `${nconf.get('url')}/uid/${uid}`,
- publicKeyPem: publicKey,
- },
-
- endpoints: {
- sharedInbox: `${nconf.get('url')}/inbox`,
+ ...{
+ '@context': [
+ 'https://www.w3.org/ns/activitystreams',
+ 'https://w3id.org/security/v1',
+ ],
+ id: `${nconf.get('url')}/uid/${uid}`,
+ url: `${nconf.get('url')}/user/${userslug}`,
+ followers: `${nconf.get('url')}/uid/${uid}/followers`,
+ following: `${nconf.get('url')}/uid/${uid}/following`,
+ inbox: `${nconf.get('url')}/uid/${uid}/inbox`,
+ outbox: `${nconf.get('url')}/uid/${uid}/outbox`,
+
+ type: 'Person',
+ name: username !== displayname ? fullname : username, // displayname is escaped, fullname is not
+ preferredUsername: userslug,
+ summary: aboutmeParsed,
+ published: new Date(joindate).toISOString(),
+ attachment,
+
+ publicKey: {
+ id: `${nconf.get('url')}/uid/${uid}#key`,
+ owner: `${nconf.get('url')}/uid/${uid}`,
+ publicKeyPem: publicKey,
+ },
+
+ endpoints: {
+ sharedInbox: `${nconf.get('url')}/inbox`,
+ },
},
+ ...(picture && { icon: picture }),
+ ...(cover && { image: cover }),
};
};