mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: closes #8308, edit post notif for watched topic posts
This commit is contained in:
@@ -81,9 +81,11 @@
|
|||||||
"notificationType_upvote": "notification",
|
"notificationType_upvote": "notification",
|
||||||
"notificationType_new-topic": "notification",
|
"notificationType_new-topic": "notification",
|
||||||
"notificationType_new-reply": "notification",
|
"notificationType_new-reply": "notification",
|
||||||
|
"notificationType_post-edit": "notification",
|
||||||
"notificationType_follow": "notification",
|
"notificationType_follow": "notification",
|
||||||
"notificationType_new-chat": "notification",
|
"notificationType_new-chat": "notification",
|
||||||
"notificationType_group-invite": "notification",
|
"notificationType_group-invite": "notification",
|
||||||
|
"notificationType_group-request-membership": "notification",
|
||||||
"notificationType_mention": "notification",
|
"notificationType_mention": "notification",
|
||||||
"notificationType_new-register": "notification",
|
"notificationType_new-register": "notification",
|
||||||
"notificationType_post-queue": "notification",
|
"notificationType_post-queue": "notification",
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
"user_posted_to_dual" : "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",
|
"user_posted_to_dual" : "<strong>%1</strong> and <strong>%2</strong> have posted replies to: <strong>%3</strong>",
|
||||||
"user_posted_to_multiple" : "<strong>%1</strong> and %2 others have posted replies to: <strong>%3</strong>",
|
"user_posted_to_multiple" : "<strong>%1</strong> and %2 others have posted replies to: <strong>%3</strong>",
|
||||||
"user_posted_topic": "<strong>%1</strong> has posted a new topic: <strong>%2</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_started_following_you": "<strong>%1</strong> started following you.",
|
"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.",
|
"user_started_following_you_dual": "<strong>%1</strong> and <strong>%2</strong> started following you.",
|
||||||
"user_started_following_you_multiple": "<strong>%1</strong> and %2 others started following you.",
|
"user_started_following_you_multiple": "<strong>%1</strong> and %2 others started following you.",
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
"notificationType_upvote": "When someone upvotes your post",
|
"notificationType_upvote": "When someone upvotes your post",
|
||||||
"notificationType_new-topic": "When someone you follow posts a topic",
|
"notificationType_new-topic": "When someone you follow posts a topic",
|
||||||
"notificationType_new-reply": "When a new reply is posted in a topic you are watching",
|
"notificationType_new-reply": "When a new reply is posted in a topic you are watching",
|
||||||
|
"notificationType_post-edit": "When a post is edited in a topic you are watching",
|
||||||
"notificationType_follow": "When someone starts following you",
|
"notificationType_follow": "When someone starts following you",
|
||||||
"notificationType_new-chat": "When you receive a chat message",
|
"notificationType_new-chat": "When you receive a chat message",
|
||||||
"notificationType_group-invite": "When you receive a group invite",
|
"notificationType_group-invite": "When you receive a group invite",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ Notifications.baseTypes = [
|
|||||||
'notificationType_upvote',
|
'notificationType_upvote',
|
||||||
'notificationType_new-topic',
|
'notificationType_new-topic',
|
||||||
'notificationType_new-reply',
|
'notificationType_new-reply',
|
||||||
|
'notificationType_post-edit',
|
||||||
'notificationType_follow',
|
'notificationType_follow',
|
||||||
'notificationType_new-chat',
|
'notificationType_new-chat',
|
||||||
'notificationType_group-invite',
|
'notificationType_group-invite',
|
||||||
|
|||||||
@@ -52,6 +52,13 @@ module.exports = function (Posts) {
|
|||||||
|
|
||||||
postData.cid = topic.cid;
|
postData.cid = topic.cid;
|
||||||
postData.topic = topic;
|
postData.topic = topic;
|
||||||
|
|
||||||
|
await topics.notifyFollowers(postData, data.uid, {
|
||||||
|
type: 'post-edit',
|
||||||
|
bodyShort: translator.compile('notifications:user_edited_post', editor.username, postData.topic.title),
|
||||||
|
nid: 'edit_post:' + postData.pid + ':uid:' + data.uid,
|
||||||
|
});
|
||||||
|
|
||||||
plugins.fireHook('action:post.edit', { post: _.clone(postData), data: data, uid: data.uid });
|
plugins.fireHook('action:post.edit', { post: _.clone(postData), data: data, uid: data.uid });
|
||||||
|
|
||||||
require('./cache').del(String(postData.pid));
|
require('./cache').del(String(postData.pid));
|
||||||
@@ -79,6 +86,7 @@ module.exports = function (Posts) {
|
|||||||
return {
|
return {
|
||||||
tid: tid,
|
tid: tid,
|
||||||
cid: topicData.cid,
|
cid: topicData.cid,
|
||||||
|
title: validator.escape(String(topicData.title)),
|
||||||
isMainPost: false,
|
isMainPost: false,
|
||||||
renamed: false,
|
renamed: false,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ var meta = require('../meta');
|
|||||||
var posts = require('../posts');
|
var posts = require('../posts');
|
||||||
var privileges = require('../privileges');
|
var privileges = require('../privileges');
|
||||||
var categories = require('../categories');
|
var categories = require('../categories');
|
||||||
|
const translator = require('../translator');
|
||||||
|
|
||||||
module.exports = function (Topics) {
|
module.exports = function (Topics) {
|
||||||
Topics.create = async function (data) {
|
Topics.create = async function (data) {
|
||||||
@@ -180,7 +181,13 @@ module.exports = function (Topics) {
|
|||||||
user.setUserField(uid, 'lastonline', Date.now());
|
user.setUserField(uid, 'lastonline', Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.notifyFollowers(postData, uid);
|
Topics.notifyFollowers(postData, uid, {
|
||||||
|
type: 'new-reply',
|
||||||
|
bodyShort: translator.compile('notifications:user_posted_to', postData.user.username, postData.topic.title),
|
||||||
|
nid: 'new_post:tid:' + postData.topic.tid + ':pid:' + postData.pid + ':uid:' + uid,
|
||||||
|
mergeId: 'notifications:user_posted_to|' + postData.topic.tid,
|
||||||
|
});
|
||||||
|
|
||||||
analytics.increment(['posts', 'posts:byCid:' + data.cid]);
|
analytics.increment(['posts', 'posts:byCid:' + data.cid]);
|
||||||
plugins.fireHook('action:topic.reply', { post: _.clone(postData), data: data });
|
plugins.fireHook('action:topic.reply', { post: _.clone(postData), data: data });
|
||||||
|
|
||||||
|
|||||||
@@ -145,47 +145,37 @@ module.exports = function (Topics) {
|
|||||||
return tids.filter((tid, index) => tid && !scores[index]);
|
return tids.filter((tid, index) => tid && !scores[index]);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.notifyFollowers = async function (postData, exceptUid) {
|
Topics.notifyFollowers = async function (postData, exceptUid, notifData) {
|
||||||
var title;
|
notifData = notifData || {};
|
||||||
var titleEscaped;
|
|
||||||
|
|
||||||
let followers = await Topics.getFollowers(postData.topic.tid);
|
let followers = await Topics.getFollowers(postData.topic.tid);
|
||||||
|
const index = followers.indexOf(String(exceptUid));
|
||||||
var index = followers.indexOf(exceptUid.toString());
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
followers.splice(index, 1);
|
followers.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
followers = await privileges.topics.filterUids('topics:read', postData.topic.tid, followers);
|
followers = await privileges.topics.filterUids('topics:read', postData.topic.tid, followers);
|
||||||
|
|
||||||
if (!followers.length) {
|
if (!followers.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
title = postData.topic.title;
|
|
||||||
|
|
||||||
|
let title = postData.topic.title;
|
||||||
if (title) {
|
if (title) {
|
||||||
title = utils.decodeHTMLEntities(title);
|
title = utils.decodeHTMLEntities(title);
|
||||||
titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
postData.content = posts.relativeToAbsolute(postData.content, posts.urlRegex);
|
postData.content = posts.relativeToAbsolute(postData.content, posts.urlRegex);
|
||||||
postData.content = posts.relativeToAbsolute(postData.content, posts.imgRegex);
|
postData.content = posts.relativeToAbsolute(postData.content, posts.imgRegex);
|
||||||
|
|
||||||
const notification = await notifications.create({
|
const notification = await notifications.create({
|
||||||
type: 'new-reply',
|
|
||||||
subject: title,
|
subject: title,
|
||||||
bodyShort: '[[notifications:user_posted_to, ' + postData.user.username + ', ' + titleEscaped + ']]',
|
|
||||||
bodyLong: postData.content,
|
bodyLong: postData.content,
|
||||||
pid: postData.pid,
|
pid: postData.pid,
|
||||||
path: '/post/' + postData.pid,
|
path: '/post/' + postData.pid,
|
||||||
nid: 'new_post:tid:' + postData.topic.tid + ':pid:' + postData.pid + ':uid:' + exceptUid,
|
|
||||||
tid: postData.topic.tid,
|
tid: postData.topic.tid,
|
||||||
from: exceptUid,
|
from: exceptUid,
|
||||||
mergeId: 'notifications:user_posted_to|' + postData.topic.tid,
|
|
||||||
topicTitle: title,
|
topicTitle: title,
|
||||||
|
...notifData,
|
||||||
});
|
});
|
||||||
if (notification) {
|
|
||||||
notifications.push(notification, followers);
|
notifications.push(notification, followers);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user