diff --git a/controllers/topic.js b/controllers/topic.js index 22bdf2d..2b6b774 100644 --- a/controllers/topic.js +++ b/controllers/topic.js @@ -36,27 +36,26 @@ exports.index = function (req, res, next) { error: '此话题不存在或已被删除。' }); } - var events = [ 'topic', 'other_topics', 'no_reply_topics', 'get_relation', '@user' ]; + var events = [ 'topic', 'other_topics', 'no_reply_topics', 'get_relation']; var ep = EventProxy.create(events, function (topic, other_topics, no_reply_topics, relation) { - res.render('topic/index', { - topic: topic, - author_other_topics: other_topics, - no_reply_topics: no_reply_topics, - relation : relation + at_ctrl.link_at_who(topic.content, function (err, content) { + if (err) { + return next(err); + } + topic.content = content; + res.render('topic/index', { + topic: topic, + author_other_topics: other_topics, + no_reply_topics: no_reply_topics, + relation : relation + }); }); }); + ep.on('error', function (err) { ep.unbind(); next(err); }); - ep.once('topic', function (topic) { - at_ctrl.link_at_who(topic.content, function (err, content) { - if (err) { - return ep.emit('error', err); - } - topic.content = content; - }); - }); get_full_topic(topic_id, function (err, message, topic, tags, author, replies) { if (err) { @@ -67,15 +66,6 @@ exports.index = function (req, res, next) { return res.render('notify/notify', { error: message }); } - - at_ctrl.link_at_who(topic.content, function (err, content) { - if (err) { - return ep.emit('error', err); - } - topic.content = content; - ep.emit('@user'); - }); - topic.visit_count += 1; topic.save(function (err) { if (!topic.content_is_html) {