diff --git a/src/topics.js b/src/topics.js index 1ba193e9ba..8215d19f26 100644 --- a/src/topics.js +++ b/src/topics.js @@ -198,7 +198,7 @@ var async = require('async'), }); } - Topics.createTopicFromPosts = function(title, pids, callback) { + Topics.createTopicFromPosts = function(uid, title, pids, callback) { if(title) { title = title.trim(); } @@ -214,6 +214,9 @@ var async = require('async'), pids.sort(); var mainPid = pids[0]; + //TODO: check if we can move all the pids, threadTools privs? -baris + + posts.getPostData(mainPid, function(err, postData) { if(err) { return callback(err); diff --git a/src/websockets.js b/src/websockets.js index fddd4beaa3..8dad9c3c18 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -623,7 +623,17 @@ websockets.init = function(io) { }); socket.on('api:topic.createTopicFromPosts', function(data, callback) { - topics.createTopicFromPosts(data.title, data.pids, function(err, data) { + if(!uid) { + socket.emit('event:alert', { + title: 'Can't fork', + message: 'Guests can't fork topics!', + type: 'warning', + timeout: 2000 + }); + return; + } + + topics.createTopicFromPosts(uid, data.title, data.pids, function(err, data) { callback(err?{message:err.message}:null, data); }); });