define all required data at top of fn

v1.18.x
psychobunny 10 years ago
parent e7fa000fe0
commit 70bf518a02

@ -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);

Loading…
Cancel
Save