mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +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 mime = require('mime');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
|
const meta = require('../meta');
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
const categories = require('../categories');
|
const categories = require('../categories');
|
||||||
const posts = require('../posts');
|
const posts = require('../posts');
|
||||||
@@ -171,15 +172,13 @@ Mocks.actors.category = async (cid) => {
|
|||||||
let { name, slug, description: summary, backgroundImage } = await categories.getCategoryData(cid);
|
let { name, slug, description: summary, backgroundImage } = await categories.getCategoryData(cid);
|
||||||
const publicKey = await activitypub.getPublicKey('cid', cid);
|
const publicKey = await activitypub.getPublicKey('cid', cid);
|
||||||
|
|
||||||
if (backgroundImage) {
|
backgroundImage = backgroundImage || meta.config['brand:logo'] || `${nconf.get('relative_path')}/assets/logo.png`;
|
||||||
const filename = utils.decodeHTMLEntities(backgroundImage).split('/').pop();
|
const filename = path.basename(utils.decodeHTMLEntities(backgroundImage));
|
||||||
const imagePath = path.join(nconf.get('upload_path'), 'category', filename);
|
backgroundImage = {
|
||||||
backgroundImage = {
|
type: 'Image',
|
||||||
type: 'Image',
|
mediaType: mime.getType(filename),
|
||||||
mediaType: mime.getType(imagePath),
|
url: `${nconf.get('url')}${utils.decodeHTMLEntities(backgroundImage)}`,
|
||||||
url: `${nconf.get('url')}${utils.decodeHTMLEntities(backgroundImage)}`,
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@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');
|
notification.bodyShort = notification.bodyShort.replace(/([\s\S]*?),[\s\S]*?,([\s\S]*?)/, '$1, [[global:guest]], $2');
|
||||||
}
|
}
|
||||||
} else if (notification.image === 'brand:logo' || !notification.image) {
|
} 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