From 70bf518a02ff2193eb5a7bc4b6595aec297efd86 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Fri, 3 Apr 2015 00:58:34 -0400 Subject: [PATCH] define all required data at top of fn --- src/topics/create.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/topics/create.js b/src/topics/create.js index f7af1d0c5e..e81e07c9ed 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -19,7 +19,8 @@ module.exports = function(Topics) { Topics.create = function(data, callback) { var uid = data.uid, title = data.title, - cid = data.cid; + cid = data.cid, + tags = data.tags; db.incrObjectField('global', 'nextTid', function(err, tid) { if (err) { @@ -78,7 +79,7 @@ module.exports = function(Topics) { db.incrObjectField('global', 'topicCount', next); }, function(next) { - Topics.createTags(data.tags, tid, timestamp, next); + Topics.createTags(tags, tid, timestamp, next); } ], function(err) { if (err) { @@ -95,7 +96,8 @@ module.exports = function(Topics) { var uid = data.uid, title = data.title, content = data.content, - cid = data.cid; + cid = data.cid, + tags = data.tags; if (title) { title = title.trim(); @@ -131,7 +133,7 @@ module.exports = function(Topics) { }, function(filteredData, next) { content = filteredData.content || data.content; - Topics.create({uid: uid, title: title, cid: cid, thumb: data.thumb, tags: data.tags}, next); + Topics.create({uid: uid, title: title, cid: cid, thumb: data.thumb, tags: tags}, next); }, function(tid, next) { Topics.reply({uid:uid, tid:tid, handle: data.handle, content:content, req: data.req}, next);