Node.js based forum software built for the modern web
refactor deleter code to use unixtimestamp
barisusakli3b41c40b938d
diff --git a/src/controllers/topics.js b/src/controllers/topics.jsindex 5202f3ac2b..1d813868ae 100644--- a/src/controllers/topics.js+++ b/src/controllers/topics.js@@ -146,24 +146,6 @@ topicsController.get = function (req, res, callback) {next(null, data.topicData);});},- function (topicData, next) {- if (!topicData.deleterUid) {- return next(null, topicData);- }-- user.getUserFields(topicData.deleterUid, ['username', 'userslug'], function(err, deleter) {- if (err) {- return next(err);- }-- topicData.deleter = deleter;- topicData.deleter.timestampISO = topicData.deletedTimestampISO- delete topicData.deleterUid;- delete topicData.deletedTimestampISO;-- next(null, topicData);- });- },function (topicData, next) {function findPost(index) {for (var i = 0; i < topicData.posts.length; i += 1) {diff --git a/src/topics.js b/src/topics.jsindex 77cea4ec98..164200016d 100644--- a/src/topics.js+++ b/src/topics.js@@ -180,6 +180,7 @@ var social = require('./social');isIgnoring: async.apply(Topics.isIgnoring, [topicData.tid], uid),bookmark: async.apply(Topics.getUserBookmark, topicData.tid, uid),postSharing: async.apply(social.getActivePostSharing),+ deleter: async.apply(getDeleter, topicData),related: function (next) {async.waterfall([function (next) {@@ -202,6 +203,8 @@ var social = require('./social');topicData.isIgnoring = results.isIgnoring[0];topicData.bookmark = results.bookmark;topicData.postSharing = results.postSharing;+ topicData.deleter = results.deleter;+ topicData.deletedTimestampISO = utils.toISOString(topicData.deletedTimestamp);topicData.related = results.related || [];topicData.unreplied = parseInt(topicData.postcount, 10) === 1;@@ -258,6 +261,13 @@ var social = require('./social');], callback);}+ function getDeleter(topicData, callback) {+ if (!topicData.deleterUid) {+ return setImmediate(callback, null, null);+ }+ user.getUserFields(topicData.deleterUid, ['username', 'userslug', 'picture'], callback);+ }+Topics.getMainPost = function (tid, uid, callback) {Topics.getMainPosts([tid], uid, function (err, mainPosts) {callback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);diff --git a/src/topics/delete.js b/src/topics/delete.jsindex b23cfbd513..30992dd94c 100644--- a/src/topics/delete.js+++ b/src/topics/delete.js@@ -21,7 +21,7 @@ module.exports = function (Topics) {Topics.setTopicFields(tid, {deleted: 1,deleterUid: uid,- deletedTimestampISO: (new Date()).toISOString()+ deletedTimestamp: Date.now(),}, next);},function (next) {@@ -52,7 +52,7 @@ module.exports = function (Topics) {Topics.setTopicField(tid, 'deleted', 0, next);},function (next) {- Topics.deleteTopicFields(tid, ['deleterUid', 'deletedTimestampISO'], next);+ Topics.deleteTopicFields(tid, ['deleterUid', 'deletedTimestamp'], next);},function (next) {Topics.updateRecent(tid, topicData.lastposttime, next);