Node.js based forum software built for the modern web
feat: show bodyLong in notifications, closes #4767
Barış Soner Uşaklı30541a9693f0
diff --git a/install/package.json b/install/package.jsonindex ce15106ad3..757acc7b0e 100644--- a/install/package.json+++ b/install/package.json@@ -97,13 +97,13 @@"multer": "2.0.2","nconf": "0.13.0","nodebb-plugin-2factor": "7.6.1",- "nodebb-plugin-composer-default": "10.3.5",+ "nodebb-plugin-composer-default": "10.3.6","nodebb-plugin-dbsearch": "6.3.5","nodebb-plugin-emoji": "6.0.5","nodebb-plugin-emoji-android": "4.1.1","nodebb-plugin-link-preview": "2.2.2","nodebb-plugin-markdown": "13.2.3",- "nodebb-plugin-mentions": "4.8.6",+ "nodebb-plugin-mentions": "4.8.7","nodebb-plugin-spam-be-gone": "2.3.2","nodebb-plugin-web-push": "0.7.6","nodebb-rewards-essentials": "1.0.2",diff --git a/public/language/en-GB/modules.json b/public/language/en-GB/modules.jsonindex f4b473992a..44e435ae33 100644--- a/public/language/en-GB/modules.json+++ b/public/language/en-GB/modules.json@@ -84,7 +84,7 @@"composer.hide-preview": "Hide Preview","composer.help": "Help","composer.user-said-in": "%1 said in %2:",- "composer.user-said": "%1 said:",+ "composer.user-said": "%1 [said](%2):","composer.discard": "Are you sure you wish to discard this post?","composer.submit-and-lock": "Submit and Lock","composer.toggle-dropdown": "Toggle Dropdown",diff --git a/public/language/en-GB/notifications.json b/public/language/en-GB/notifications.jsonindex 065cd6aeed..1a14907ee0 100644--- a/public/language/en-GB/notifications.json+++ b/public/language/en-GB/notifications.json@@ -36,33 +36,33 @@"user-posted-in-public-room-dual": "<strong>%1</strong> and <strong>%2</strong> wrote in <strong class=\"text-nowrap\"><i class=\"fa %3\"></i>%4</strong>","user-posted-in-public-room-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> wrote in <strong class=\"text-nowrap\"><i class=\"fa %4\"></i>%5</strong>","user-posted-in-public-room-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others wrote in <strong class=\"text-nowrap\"><i class=\"fa %4\"></i>%5</strong>",- "upvoted-your-post-in": "<strong>%1</strong> has upvoted your post in <strong>%2</strong>.",- "upvoted-your-post-in-dual": "<strong>%1</strong> and <strong>%2</strong> have upvoted your post in <strong>%3</strong>.",- "upvoted-your-post-in-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> have upvoted your post in <strong>%4</strong>.",- "upvoted-your-post-in-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others have upvoted your post in <strong>%4</strong>.",+ "upvoted-your-post-in": "<strong>%1</strong> upvoted<br/><strong>%2</strong>",+ "upvoted-your-post-in-dual": "<strong>%1</strong> and <strong>%2</strong> upvoted<br/><strong>%3</strong>",+ "upvoted-your-post-in-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> upvoted<br/><strong>%4</strong>",+ "upvoted-your-post-in-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others upvoted<br/><strong>%4</strong>.","moved-your-post": "<strong>%1</strong> has moved your post to <strong>%2</strong>","moved-your-topic": "<strong>%1</strong> has moved <strong>%2</strong>",- "user-flagged-post-in": "<strong>%1</strong> flagged a post in <strong>%2</strong>",- "user-flagged-post-in-dual": "<strong>%1</strong> and <strong>%2</strong> flagged a post in <strong>%3</strong>",- "user-flagged-post-in-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a post in <strong>%4</strong>",- "user-flagged-post-in-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a post in <strong>%4</strong>",+ "user-flagged-post-in": "<strong>%1</strong> flagged a post<br/><strong>%2</strong>",+ "user-flagged-post-in-dual": "<strong>%1</strong> and <strong>%2</strong> flagged a post<br/><strong>%3</strong>",+ "user-flagged-post-in-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a post<br/><strong>%4</strong>",+ "user-flagged-post-in-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a post<br/><strong>%4</strong>","user-flagged-user": "<strong>%1</strong> flagged a user profile (%2)","user-flagged-user-dual": "<strong>%1</strong> and <strong>%2</strong> flagged a user profile (%3)","user-flagged-user-triple": "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> flagged a user profile (%4)","user-flagged-user-multiple": "<strong>%1</strong>, <strong>%2</strong> and %3 others flagged a user profile (%4)",- "user-posted-to" : "<strong>%1</strong> has posted a reply to: <strong>%2</strong>",- "user-posted-to-dual" : "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",- "user-posted-to-triple" : "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> have posted replies to: <strong>%4</strong>",- "user-posted-to-multiple" : "<strong>%1</strong>, <strong>%2</strong> and %3 others have posted replies to: <strong>%4</strong>",- "user-posted-topic": "<strong>%1</strong> has posted a new topic: <strong>%2</strong>",- "user-edited-post" : "<strong>%1</strong> has edited a post in <strong>%2</strong>",+ "user-posted-to" : "<strong>%1</strong> replied in<br/><strong>%2</strong>",+ "user-posted-to-dual" : "<strong>%1</strong> and <strong>%2</strong> replied in<br/><strong>%3</strong>",+ "user-posted-to-triple" : "<strong>%1</strong>, <strong>%2</strong> and <strong>%3</strong> replied in<br/><strong>%4</strong>",+ "user-posted-to-multiple" : "<strong>%1</strong>, <strong>%2</strong> and %3 others replied in<br/><strong>%4</strong>",+ "user-posted-topic": "<strong>%1</strong> posted<br/><strong>%2</strong>",+ "user-edited-post" : "<strong>%1</strong> edited a post in<br/><strong>%2</strong>",- "user-posted-topic-with-tag": "<strong>%1</strong> has posted <strong>%2</strong> (tagged %3)",- "user-posted-topic-with-tag-dual": "<strong>%1</strong> has posted <strong>%2</strong> (tagged %3 and %4)",- "user-posted-topic-with-tag-triple": "<strong>%1</strong> has posted <strong>%2</strong> (tagged %3, %4, and %5)",- "user-posted-topic-with-tag-multiple": "<strong>%1</strong> has posted <strong>%2</strong> (tagged %3)",+ "user-posted-topic-with-tag": "<strong>%1</strong> posted<br/><strong>%2</strong> (tagged %3)",+ "user-posted-topic-with-tag-dual": "<strong>%1</strong> posted<br/><strong>%2</strong> (tagged %3 and %4)",+ "user-posted-topic-with-tag-triple": "<strong>%1</strong> posted<br/><strong>%2</strong> (tagged %3, %4, and %5)",+ "user-posted-topic-with-tag-multiple": "<strong>%1</strong> posted<br/><strong>%2</strong> (tagged %3)",- "user-posted-topic-in-category": "<strong>%1</strong> has posted a new topic in <strong>%2</strong>",+ "user-posted-topic-in-category": "<strong>%1</strong> posted<br/><strong>%2</strong> (category %3)","user-started-following-you": "<strong>%1</strong> started following you.","user-started-following-you-dual": "<strong>%1</strong> and <strong>%2</strong> started following you.",diff --git a/public/scss/generics.scss b/public/scss/generics.scssindex 0938613ec9..0e8d33371b 100644--- a/public/scss/generics.scss+++ b/public/scss/generics.scss@@ -145,6 +145,18 @@ blockquote {}}+.hidden-blockquote {+ blockquote {+ display: none;+ }+}++.hidden-leading-br {+ > br:first-child {+ display: none;+ }+}+// some classes that are used commonly in themes from bs3.hidden, .hide {display: none!important;diff --git a/src/categories/topics.js b/src/categories/topics.jsindex 5169998910..633779ef89 100644--- a/src/categories/topics.js+++ b/src/categories/topics.js@@ -237,10 +237,14 @@ module.exports = function (Categories) {}const { displayname } = postData.user;- const categoryName = await Categories.getCategoryField(cid, 'name');+ const [categoryName, title] = await Promise.all([+ Categories.getCategoryField(cid, 'name'),+ topics.getTopicField(postData.topic.tid, 'title'),+ ]);+const notifBase = 'notifications:user-posted-topic-in-category';- const bodyShort = translator.compile(notifBase, displayname, categoryName);+ const bodyShort = translator.compile(notifBase, displayname, title, categoryName);const notification = await notifications.create({type: 'new-topic-in-category',diff --git a/src/flags.js b/src/flags.jsindex 435bc10c42..0ff9152978 100644--- a/src/flags.js+++ b/src/flags.js@@ -934,7 +934,7 @@ Flags.notify = async function (flagObj, uid, notifySelf = false) {notifObj = await notifications.create({type: 'new-post-flag',bodyShort: `[[notifications:user-flagged-post-in, ${displayname}, ${titleEscaped}]]`,- bodyLong: await plugins.hooks.fire('filter:parse.raw', String(flagObj.description || '')),+ bodyLong: String(flagObj.target?.content || ''),pid: flagObj.targetId,path: `/flags/${flagObj.flagId}`,nid: `flag:post:${flagObj.targetId}:${uid}`,diff --git a/src/posts/edit.js b/src/posts/edit.jsindex 0b8b6ff009..3d6d729351 100644--- a/src/posts/edit.js+++ b/src/posts/edit.js@@ -84,20 +84,25 @@ module.exports = function (Posts) {returnPostData.oldContent = oldContent;returnPostData.newContent = data.content;- await topics.notifyFollowers(returnPostData, data.uid, {- type: 'post-edit',- bodyShort: translator.compile('notifications:user-edited-post', editor.username, topic.title),- nid: `edit_post:${data.pid}:uid:${data.uid}`,- });await topics.syncBacklinks(returnPostData);- plugins.hooks.fire('action:post.edit', { post: { ...returnPostData, _activitypub }, data: data, uid: data.uid });+ plugins.hooks.fire('action:post.edit', {+ post: { ...returnPostData, _activitypub },+ data: data,+ uid: data.uid,+ });Posts.clearCachedPost(String(postData.pid));pubsub.publish('post:edit', String(postData.pid));await Posts.parsePost(returnPostData);+ await topics.notifyFollowers(returnPostData, data.uid, {+ type: 'post-edit',+ bodyShort: translator.compile('notifications:user-edited-post', editor.username, topic.title),+ nid: `edit_post:${data.pid}:uid:${data.uid}`,+ });+return {topic: topic,editor: editor,