fix: serve category actor image instead of nothing, serve brand logo in icon

This commit is contained in:
Julian Lam
2024-08-06 15:06:01 -04:00
parent d33fb92d9d
commit cbe0a0ad5c

View File

@@ -204,18 +204,28 @@ Mocks.actors.user = async (uid) => {
}; };
Mocks.actors.category = async (cid) => { Mocks.actors.category = async (cid) => {
let { const {
name, handle: preferredUsername, slug, name, handle: preferredUsername, slug,
descriptionParsed: summary, backgroundImage, descriptionParsed: summary, backgroundImage,
} = await categories.getCategoryData(cid); } = await categories.getCategoryData(cid);
const publicKey = await activitypub.getPublicKey('cid', cid); const publicKey = await activitypub.getPublicKey('cid', cid);
backgroundImage = backgroundImage || meta.config['brand:logo'] || `${nconf.get('relative_path')}/assets/logo.png`; let image;
const filename = path.basename(utils.decodeHTMLEntities(backgroundImage)); if (backgroundImage) {
backgroundImage = { const filename = path.basename(utils.decodeHTMLEntities(backgroundImage));
image = {
type: 'Image',
mediaType: mime.getType(filename),
url: `${nconf.get('url')}${utils.decodeHTMLEntities(backgroundImage)}`,
};
}
let icon = meta.config['brand:logo'] || `${nconf.get('relative_path')}/assets/logo.png`;
const filename = path.basename(utils.decodeHTMLEntities(icon));
icon = {
type: 'Image', type: 'Image',
mediaType: mime.getType(filename), mediaType: mime.getType(filename),
url: `${nconf.get('url')}${utils.decodeHTMLEntities(backgroundImage)}`, url: `${nconf.get('url')}${utils.decodeHTMLEntities(icon)}`,
}; };
return { return {
@@ -234,7 +244,8 @@ Mocks.actors.category = async (cid) => {
name, name,
preferredUsername, preferredUsername,
summary, summary,
icon: backgroundImage, image,
icon,
publicKey: { publicKey: {
id: `${nconf.get('url')}/category/${cid}#key`, id: `${nconf.get('url')}/category/${cid}#key`,