Skip to content

Node.js based forum software built for the modern web

fix: serve fallback images on category actor

Julian Lam8cb984d44c05
diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js
index fd6ac41fe2..b86f3516fe 100644
--- a/src/activitypub/mocks.js
+++ b/src/activitypub/mocks.js
@@ -4,6 +4,7 @@ const nconf = require('nconf');
const mime = require('mime');
const path = require('path');
+const meta = require('../meta');
const user = require('../user');
const categories = require('../categories');
const posts = require('../posts');
@@ -171,15 +172,13 @@ Mocks.actors.category = async (cid) => {
let { name, slug, description: summary, backgroundImage } = await categories.getCategoryData(cid);
const publicKey = await activitypub.getPublicKey('cid', cid);
- if (backgroundImage) {
- const filename = utils.decodeHTMLEntities(backgroundImage).split('/').pop();
- const imagePath = path.join(nconf.get('upload_path'), 'category', filename);
- backgroundImage = {
- type: 'Image',
- mediaType: mime.getType(imagePath),
- url: `${nconf.get('url')}${utils.decodeHTMLEntities(backgroundImage)}`,
- };
- }
+ backgroundImage = backgroundImage || meta.config['brand:logo'] || `${nconf.get('relative_path')}/assets/logo.png`;
+ const filename = path.basename(utils.decodeHTMLEntities(backgroundImage));
+ backgroundImage = {
+ type: 'Image',
+ mediaType: mime.getType(filename),
+ url: `${nconf.get('url')}${utils.decodeHTMLEntities(backgroundImage)}`,
+ };
return {
'@context': 'https://www.w3.org/ns/activitystreams',
diff --git a/src/notifications.js b/src/notifications.js
index 612c67d95f..12a43af793 100644
--- a/src/notifications.js
+++ b/src/notifications.js
@@ -107,7 +107,7 @@ Notifications.getMultiple = async function (nids) {
notification.bodyShort = notification.bodyShort.replace(/([\s\S]*?),[\s\S]*?,([\s\S]*?)/, '$1, [[global:guest]], $2');
}
} else if (notification.image === 'brand:logo' || !notification.image) {
- notification.image = meta.config['brand:logo'] || `${nconf.get('relative_path')}/logo.png`;
+ notification.image = meta.config['brand:logo'] || `${nconf.get('relative_path')}/assets/logo.png`;
}
}
});