fix: serve fallback images on category actor

This commit is contained in:
Julian Lam
2024-02-28 14:07:27 -05:00
parent 44452a3b6e
commit 8cb984d44c
2 changed files with 9 additions and 10 deletions

View File

@@ -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',

View File

@@ -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`;
}
}
});