mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
fix: serve fallback images on category actor
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -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`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user