Skip to content

Node.js based forum software built for the modern web

closes #2969

Barış Soner Uşaklıdf3e00712008
diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js
index 77690dc9d9..0090e37af9 100644
--- a/public/src/client/topic/events.js
+++ b/public/src/client/topic/events.js
@@ -100,7 +100,7 @@ define('forum/topic/events', [
var editedPostEl = components.get('post/content', data.pid),
topicTitle = components.get('topic/title');
- if (topicTitle.length) {
+ if (topicTitle.length && data.title) {
topicTitle.fadeOut(250, function() {
topicTitle.html(data.title).fadeIn(250);
});
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index d1a5bb7e39..d8a3104397 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -306,16 +306,41 @@ SocketPosts.edit = function(socket, data, callback) {
return callback(err);
}
- websockets.in('topic_' + results.topic.tid).emit('event:post_edited', {
+ var result = {
pid: data.pid,
handle: data.handle,
title: results.topic.title,
isMainPost: results.topic.isMainPost,
tags: results.topic.tags,
content: results.content
- });
+ };
+ if (parseInt(results.postData.deleted) !== 1) {
+ websockets.in('topic_' + results.topic.tid).emit('event:post_edited', result);
+ callback();
+ return;
+ }
+
+ socket.emit('event:post_edited', result);
callback();
+
+ async.parallel({
+ admins: async.apply(groups.getMembers, 'administrators', 0, -1),
+ moderators: async.apply(groups.getMembers, 'cid:' + results.topic.cid + ':privileges:mods', 0, -1),
+ uidsInTopic: async.apply(websockets.getUidsInRoom, 'topic_' + results.topic.tid)
+ }, function(err, results) {
+ if (err) {
+ return winston.error(err);
+ }
+
+ var uids = results.uidsInTopic.filter(function(uid) {
+ return results.admins.indexOf(uid) !== -1 || results.moderators.indexOf(uid) !== -1;
+ });
+
+ uids.forEach(function(uid) {
+ websockets.in('uid_' + uid).emit('event:post_edited', result);
+ });
+ });
});
};