diff --git a/public/language/en-GB/admin/manage/categories.json b/public/language/en-GB/admin/manage/categories.json index 9965edf634..f51152f22d 100644 --- a/public/language/en-GB/admin/manage/categories.json +++ b/public/language/en-GB/admin/manage/categories.json @@ -10,6 +10,9 @@ "handle": "Category Handle", "handle.help": "Your category handle is used as a representation of this category across other networks, similar to a username. A category handle must not match an existing username or user group.", "description": "Category Description", + "federatedDescription": "Federated Description", + "federatedDescription.help": "This text will be appended to the category description when queried by other websites/apps.", + "federatedDescription.default": "This is a forum category containing topical discussion. You can start new discussions by mentioning this category.", "bg-color": "Background Colour", "text-color": "Text Colour", "bg-image-size": "Background Image Size", diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js index 290ab13fc8..9ca0968b68 100644 --- a/src/activitypub/mocks.js +++ b/src/activitypub/mocks.js @@ -413,10 +413,11 @@ Mocks.actors.user = async (uid) => { }; Mocks.actors.category = async (cid) => { - const { + let { name, handle: preferredUsername, slug, - descriptionParsed: summary, backgroundImage, - } = await categories.getCategoryData(cid); + descriptionParsed: summary, federatedDescription, backgroundImage, + } = await categories.getCategoryFields(cid, + ['name', 'handle', 'slug', 'description', 'descriptionParsed', 'federatedDescription', 'backgroundImage']); const publicKey = await activitypub.getPublicKey('cid', cid); let icon; @@ -437,6 +438,9 @@ Mocks.actors.category = async (cid) => { }; } + // Append federated desc. + const fallback = await translator.translate('[[admin/manage/categories:federatedDescription.default]]'); + summary += `

${federatedDescription || fallback}

\n`; return { '@context': [ diff --git a/src/categories/data.js b/src/categories/data.js index 8890abf670..9ad2783203 100644 --- a/src/categories/data.js +++ b/src/categories/data.js @@ -117,7 +117,7 @@ function modifyCategory(category, fields) { db.parseIntFields(category, intFields, fields); - const escapeFields = ['name', 'color', 'bgColor', 'backgroundImage', 'imageClass', 'class', 'link']; + const escapeFields = ['name', 'description', 'federatedDescription', 'color', 'bgColor', 'backgroundImage', 'imageClass', 'class', 'link']; escapeFields.forEach((field) => { if (category.hasOwnProperty(field)) { category[field] = validator.escape(String(category[field] || '')); @@ -137,7 +137,6 @@ function modifyCategory(category, fields) { } if (category.description) { - category.description = validator.escape(String(category.description)); category.descriptionParsed = category.descriptionParsed || category.description; } } diff --git a/src/views/admin/manage/category.tpl b/src/views/admin/manage/category.tpl index f57c6ab463..5d3b84c639 100644 --- a/src/views/admin/manage/category.tpl +++ b/src/views/admin/manage/category.tpl @@ -36,6 +36,16 @@ +
+ + +

+ [[admin/manage/categories:federatedDescription.help]] +

+
+