mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-09 15:35:47 +01:00
closes #1369
This commit is contained in:
@@ -71,5 +71,8 @@
|
||||
"notification_sounds" : "Play a sound when you receive a notification.",
|
||||
|
||||
"browsing": "Browsing Settings",
|
||||
"open_links_in_new_tab": "Open outgoing links in new tab?"
|
||||
"open_links_in_new_tab": "Open outgoing links in new tab?",
|
||||
|
||||
"follow_topics_you_reply_to": "Follow topics that you reply to.",
|
||||
"follow_topics_you_create": "Follow topics you create."
|
||||
}
|
||||
|
||||
@@ -240,4 +240,19 @@ var winston = require('winston'),
|
||||
], callback);
|
||||
};
|
||||
|
||||
ThreadTools.follow = function(tid, uid, callback) {
|
||||
callback = callback || function() {};
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
ThreadTools.exists(tid, next);
|
||||
},
|
||||
function (exists, next) {
|
||||
if (!exists) {
|
||||
return next(new Error('[[error:no-topic]]'));
|
||||
}
|
||||
db.setAdd('tid:' + tid + ':followers', uid, next);
|
||||
}
|
||||
], callback);
|
||||
};
|
||||
|
||||
}(exports));
|
||||
|
||||
@@ -105,9 +105,6 @@ module.exports = function(Topics) {
|
||||
if(!canCreate) {
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
next();
|
||||
},
|
||||
function(next) {
|
||||
user.isReadyToPost(uid, next);
|
||||
},
|
||||
function(next) {
|
||||
@@ -115,35 +112,46 @@ module.exports = function(Topics) {
|
||||
},
|
||||
function(filteredData, next) {
|
||||
content = filteredData.content || data.content;
|
||||
next();
|
||||
},
|
||||
function(next) {
|
||||
Topics.create({uid: uid, title: title, cid: cid, thumb: data.thumb, tags: data.tags}, next);
|
||||
},
|
||||
function(tid, next) {
|
||||
Topics.reply({uid:uid, tid:tid, content:content, req: data.req}, next);
|
||||
},
|
||||
function(postData, next) {
|
||||
threadTools.toggleFollow(postData.tid, uid);
|
||||
async.parallel({
|
||||
postData: function(next) {
|
||||
next(null, postData);
|
||||
},
|
||||
function(postData, next) {
|
||||
Topics.getTopicsByTids([postData.tid], 0, function(err, topicData) {
|
||||
if(err) {
|
||||
settings: function(next) {
|
||||
user.getSettings(uid, function(err, settings) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
if(!topicData || !topicData.length) {
|
||||
if (settings.followTopicsOnCreate) {
|
||||
threadTools.follow(postData.tid, uid, next);
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
},
|
||||
topicData: function(next) {
|
||||
Topics.getTopicsByTids([postData.tid], 0, next);
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
function(data, next) {
|
||||
if(!Array.isArray(data.topicData) || !data.topicData.length) {
|
||||
return next(new Error('[[error:no-topic]]'));
|
||||
}
|
||||
topicData = topicData[0];
|
||||
topicData.unreplied = 1;
|
||||
|
||||
plugins.fireHook('action:topic.post', topicData);
|
||||
data.topicData = data.topicData[0];
|
||||
data.topicData.unreplied = 1;
|
||||
|
||||
plugins.fireHook('action:topic.post', data.topicData);
|
||||
|
||||
next(null, {
|
||||
topicData: topicData,
|
||||
postData: postData
|
||||
});
|
||||
topicData: data.topicData,
|
||||
postData: data.postData
|
||||
});
|
||||
}
|
||||
], callback);
|
||||
@@ -178,9 +186,6 @@ module.exports = function(Topics) {
|
||||
if (!canReply) {
|
||||
return next(new Error('[[error:no-privileges]]'));
|
||||
}
|
||||
next();
|
||||
},
|
||||
function(next) {
|
||||
user.isReadyToPost(uid, next);
|
||||
},
|
||||
function(next) {
|
||||
@@ -215,6 +220,12 @@ module.exports = function(Topics) {
|
||||
function(topicData, next) {
|
||||
topicData.title = validator.escape(topicData.title);
|
||||
postData.topic = topicData;
|
||||
user.getSettings(uid, next);
|
||||
},
|
||||
function(settings, next) {
|
||||
if (settings.followTopicsOnReply) {
|
||||
threadTools.follow(postData.tid, uid);
|
||||
}
|
||||
posts.getPidIndex(postData.pid, next);
|
||||
},
|
||||
function(index, next) {
|
||||
|
||||
@@ -33,6 +33,8 @@ module.exports = function(User) {
|
||||
settings.notificationSounds = settings.notificationSounds ? parseInt(settings.notificationSounds, 10) === 1 : true;
|
||||
settings.language = settings.language || meta.config.defaultLang || 'en_GB';
|
||||
settings.topicPostSort = settings.topicPostSort || meta.config.topicPostSort || 'oldest_to_newest';
|
||||
settings.followTopicsOnCreate = settings.followTopicsOnCreate ? parseInt(settings.followTopicsOnCreate, 10) === 1 : true;
|
||||
settings.followTopicsOnReply = settings.followTopicsOnReply ? parseInt(settings.followTopicsOnReply, 10) === 1 : false;
|
||||
callback(null, settings);
|
||||
});
|
||||
});
|
||||
@@ -80,7 +82,9 @@ module.exports = function(User) {
|
||||
topicsPerPage: data.topicsPerPage,
|
||||
postsPerPage: data.postsPerPage,
|
||||
notificationSounds: data.notificationSounds,
|
||||
language: data.language || meta.config.defaultLang
|
||||
language: data.language || meta.config.defaultLang,
|
||||
followTopicsOnCreate: data.followTopicsOnCreate,
|
||||
followTopicsOnReply: data.followTopicsOnReply
|
||||
}, callback);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user