mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 04:37:51 +02:00
Merge branch 'master' into less-is-moar
This commit is contained in:
@@ -983,8 +983,6 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
};
|
||||
|
||||
function updateHeader() {
|
||||
var paginationEl = $('#pagination');
|
||||
|
||||
$('.pagination-block a').off('click').on('click', function() {
|
||||
return false;
|
||||
});
|
||||
@@ -997,16 +995,10 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
app.scrollToBottom();
|
||||
});
|
||||
|
||||
var windowHeight = jQuery(window).height();
|
||||
var scrollTop = jQuery(window).scrollTop();
|
||||
var scrollBottom = scrollTop + windowHeight;
|
||||
var progressBar = $('.progress-bar');
|
||||
var tid = templates.get('topic_id');
|
||||
|
||||
if(scrollTop > 50) {
|
||||
$('#header-topic-title').html(templates.get('topic_name')).show();
|
||||
if($(window).scrollTop() > 50) {
|
||||
$('#header-topic-title').text(templates.get('topic_name')).show();
|
||||
} else {
|
||||
$('#header-topic-title').html('').hide();
|
||||
$('#header-topic-title').text('').hide();
|
||||
}
|
||||
|
||||
$($('.posts > .post-row').get().reverse()).each(function() {
|
||||
@@ -1017,8 +1009,8 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
if(index > Topic.postCount) {
|
||||
index = Topic.postCount;
|
||||
}
|
||||
paginationEl.html(index + ' out of ' + Topic.postCount);
|
||||
progressBar.width((index / Topic.postCount * 100) + '%');
|
||||
$('#pagination').html(index + ' out of ' + Topic.postCount);
|
||||
$('.progress-bar').width((index / Topic.postCount * 100) + '%');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -1028,9 +1020,9 @@ define(['composer', 'forum/pagination'], function(composer, pagination) {
|
||||
if (elementInView(el)) {
|
||||
var index = parseInt(el.attr('data-index'), 10) + 1;
|
||||
if(index === 0) {
|
||||
localStorage.removeItem("topic:" + tid + ":bookmark");
|
||||
localStorage.removeItem("topic:" + templates.get('topic_id') + ":bookmark");
|
||||
} else {
|
||||
localStorage.setItem("topic:" + tid + ":bookmark", el.attr('data-pid'));
|
||||
localStorage.setItem("topic:" + templates.get('topic_id') + ":bookmark", el.attr('data-pid'));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
<ul id="topics-container" itemscope itemtype="http://www.schema.org/ItemList" data-nextstart="{nextStart}">
|
||||
<meta itemprop="itemListOrder" content="descending">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class} {topics.unread-class}" itemprop="itemListElement">
|
||||
<li class="category-item <!-- IF topics.deleted -->deleted<!-- ENDIF topics.deleted --><!-- IF topics.unread -->unread<!-- ENDIF topics.unread -->" itemprop="itemListElement">
|
||||
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<a href="../../topic/{topics.slug}" itemprop="url">
|
||||
<meta itemprop="name" content="{topics.title}">
|
||||
|
||||
<strong><i class="fa {topics.pin-icon}"></i> <i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -74,13 +74,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="../../user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="../../user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="../../topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="../../topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
<div class="col-md-12">
|
||||
<ul id="topics-container" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class} {topics.unread-class}">
|
||||
<li class="category-item <!-- IF topics.deleted --> deleted<!-- ENDIF topics.deleted --><!-- IF topics.unread --> unread<!-- ENDIF topics.unread -->">
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
|
||||
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
<h3>
|
||||
<a href="{relative_path}/topic/{topics.slug}">
|
||||
<strong><i class="fa {topics.pin-icon}"></i><i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -50,8 +50,8 @@
|
||||
|
|
||||
<span>
|
||||
[[category:posted]] [[global:in]]
|
||||
<a href="{relative_path}/category/{topics.categorySlug}">
|
||||
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
|
||||
<a href="{relative_path}/category/{topics.category.slug}">
|
||||
<i class="fa {topics.category.icon}"></i> {topics.category.name}
|
||||
</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
@@ -61,13 +61,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="{relative_path}/user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="{relative_path}/user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="col-md-12">
|
||||
<ul id="topics-container" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class} {topics.unread-class}">
|
||||
<li class="category-item <!-- IF topics.deleted --> deleted<!-- ENDIF topics.deleted --><!-- IF topics.unread --> unread<!-- ENDIF topics.unread -->">
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
|
||||
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<h3>
|
||||
<a href="{relative_path}/topic/{topics.slug}">
|
||||
<strong><i class="fa {topics.pin-icon}"></i><i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -51,9 +51,7 @@
|
||||
|
|
||||
<span>
|
||||
[[category:posted]] [[global:in]]
|
||||
<a href="{relative_path}/category/{topics.categorySlug}">
|
||||
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
|
||||
</a>
|
||||
<a href="{relative_path}/category/{topics.category.slug}"><i class="fa {topics.category.icon}"></i> {topics.category.name}</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
</span>
|
||||
@@ -62,13 +60,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="{relative_path}/user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="{relative_path}/user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -19,14 +19,14 @@
|
||||
<div class="col-md-12">
|
||||
<ul id="topics-container" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN topics -->
|
||||
<li class="category-item {topics.deleted-class}">
|
||||
<li class="category-item <!-- IF topics.deleted --> deleted<!-- ENDIF topics.deleted -->">
|
||||
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
|
||||
<a href="{relative_path}/user/{topics.userslug}" class="pull-left">
|
||||
<img class="img-rounded user-img" src="{topics.picture}" title="{topics.username}" />
|
||||
</a>
|
||||
<h3>
|
||||
<a href="{relative_path}/topic/{topics.slug}">
|
||||
<strong><i class="fa {topics.pin-icon}"></i><i class="fa {topics.lock-icon}"></i></strong>
|
||||
<strong><!-- IF topics.pinned --><i class="fa fa-thumb-tack"></i><!-- ENDIF topics.pinned --> <!-- IF topics.locked --><i class="fa fa-lock"></i><!-- ENDIF topics.locked --></strong>
|
||||
<span class="topic-title">{topics.title}</span>
|
||||
</a>
|
||||
</h3>
|
||||
@@ -44,9 +44,7 @@
|
||||
|
|
||||
<span>
|
||||
[[category:posted]] [[global:in]]
|
||||
<a href="{relative_path}/category/{topics.categorySlug}">
|
||||
<i class="fa {topics.categoryIcon}"></i> {topics.categoryName}
|
||||
</a>
|
||||
<a href="{relative_path}/category/{topics.category.slug}"><i class="fa {topics.category.icon}"></i> {topics.category.name}</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
</span>
|
||||
@@ -55,13 +53,13 @@
|
||||
<!-- IF topics.unreplied -->
|
||||
[[category:no_replies]]
|
||||
<!-- ELSE -->
|
||||
<a href="{relative_path}/user/{topics.teaser_userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser_userpicture}" title="{topics.teaser_username}"/>
|
||||
<a href="{relative_path}/user/{topics.teaser.userslug}">
|
||||
<img class="teaser-pic" src="{topics.teaser.picture}" title="{topics.teaser.username}"/>
|
||||
</a>
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser_pid}">
|
||||
<a href="{relative_path}/topic/{topics.slug}#{topics.teaser.pid}">
|
||||
[[category:replied]]
|
||||
</a>
|
||||
<span class="timeago" title="{topics.teaser_timestamp}"></span>
|
||||
<span class="timeago" title="{topics.teaser.timestamp}"></span>
|
||||
<!-- ENDIF topics.unreplied -->
|
||||
</span>
|
||||
</small>
|
||||
|
||||
@@ -153,7 +153,11 @@ var winston = require('winston'),
|
||||
|
||||
// Delete the thread if it is the last undeleted post
|
||||
threadTools.getLatestUndeletedPid(postData.tid, function(err, pid) {
|
||||
if (err && err.message === 'no-undeleted-pids-found') {
|
||||
if(err) {
|
||||
return winston.error(err.message);
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
threadTools.delete(postData.tid, uid, function(err) {
|
||||
if (err) {
|
||||
winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
|
||||
@@ -166,7 +170,6 @@ var winston = require('winston'),
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
callback(null);
|
||||
});
|
||||
};
|
||||
@@ -182,7 +185,6 @@ var winston = require('winston'),
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
PostTools.restore = function(uid, pid, callback) {
|
||||
|
||||
@@ -310,8 +310,9 @@ var winston = require('winston'),
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (pids.length === 0) {
|
||||
return callback(new Error('no-undeleted-pids-found'));
|
||||
return callback(null, null);
|
||||
}
|
||||
|
||||
async.detectSeries(pids, function(pid, next) {
|
||||
@@ -322,7 +323,7 @@ var winston = require('winston'),
|
||||
if (pid) {
|
||||
callback(null, pid);
|
||||
} else {
|
||||
callback(new Error('no-undeleted-pids-found'));
|
||||
callback(null, null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
162
src/topics.js
162
src/topics.js
@@ -134,12 +134,16 @@ var async = require('async'),
|
||||
next(null, postData);
|
||||
},
|
||||
function(postData, next) {
|
||||
Topics.getTopicForCategoryView(postData.tid, uid, function(err, topicData) {
|
||||
Topics.getTopicsByTids([postData.tid], data.cid, uid, function(err, topicData) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
if(!topicData || !topicData.length) {
|
||||
return next(new Error('no-topic'));
|
||||
}
|
||||
topicData = topicData[0];
|
||||
topicData.unreplied = 1;
|
||||
|
||||
next(null, {
|
||||
topicData: topicData,
|
||||
postData: postData
|
||||
@@ -325,18 +329,22 @@ var async = require('async'),
|
||||
|
||||
Topics.getTopicDataWithUser = function(tid, callback) {
|
||||
Topics.getTopicData(tid, function(err, topic) {
|
||||
if(err || !topic) {
|
||||
if (err || !topic) {
|
||||
return callback(err || new Error('topic doesn\'t exist'));
|
||||
}
|
||||
|
||||
user.getUserFields(topic.uid, ['username', 'userslug', 'picture'] , function(err, userData) {
|
||||
if(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
topic.username = userData.username;
|
||||
topic.userslug = userData.userslug
|
||||
topic.picture = userData.picture;
|
||||
if (!userData) {
|
||||
userData = {};
|
||||
}
|
||||
|
||||
topic.username = userData.username || 'Anonymous';
|
||||
topic.userslug = userData.userslug || '';
|
||||
topic.picture = userData.picture || gravatar.url('', {}, true);
|
||||
callback(null, topic);
|
||||
});
|
||||
});
|
||||
@@ -669,47 +677,20 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
function getTopicInfo(topicData, callback) {
|
||||
|
||||
function getUserInfo(next) {
|
||||
user.getUserFields(topicData.uid, ['username', 'userslug', 'picture'], next);
|
||||
}
|
||||
|
||||
function hasReadTopic(next) {
|
||||
Topics.hasReadTopic(topicData.tid, current_user, next);
|
||||
}
|
||||
|
||||
function getTeaserInfo(next) {
|
||||
Topics.getTeaser(topicData.tid, function(err, teaser) {
|
||||
next(null, teaser || {});
|
||||
});
|
||||
}
|
||||
|
||||
// temporary. I don't think this call should belong here
|
||||
|
||||
function getPrivileges(next) {
|
||||
categoryTools.privileges(cid, current_user, next);
|
||||
}
|
||||
|
||||
function getCategoryInfo(next) {
|
||||
categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], next);
|
||||
}
|
||||
|
||||
async.parallel([getUserInfo, hasReadTopic, getTeaserInfo, getPrivileges, getCategoryInfo], function(err, results) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
async.parallel({
|
||||
hasread : function (next) {
|
||||
Topics.hasReadTopic(topicData.tid, current_user, next);
|
||||
},
|
||||
teaser : function (next) {
|
||||
Topics.getTeaser(topicData.tid, next);
|
||||
},
|
||||
privileges : function (next) {
|
||||
categoryTools.privileges(topicData.cid, current_user, next);
|
||||
},
|
||||
categoryData : function (next) {
|
||||
categories.getCategoryFields(topicData.cid, ['name', 'slug', 'icon'], next);
|
||||
}
|
||||
|
||||
callback(null, {
|
||||
username: results[0].username,
|
||||
userslug: results[0].userslug,
|
||||
picture: results[0].picture,
|
||||
userbanned: results[0].banned,
|
||||
hasread: results[1],
|
||||
teaserInfo: results[2],
|
||||
privileges: results[3],
|
||||
categoryData: results[4]
|
||||
});
|
||||
});
|
||||
}, callback);
|
||||
}
|
||||
|
||||
function isTopicVisible(topicData, topicInfo) {
|
||||
@@ -719,7 +700,8 @@ var async = require('async'),
|
||||
}
|
||||
|
||||
function loadTopic(tid, next) {
|
||||
Topics.getTopicData(tid, function(err, topicData) {
|
||||
|
||||
Topics.getTopicDataWithUser(tid, function(err, topicData) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
@@ -737,25 +719,14 @@ var async = require('async'),
|
||||
return next();
|
||||
}
|
||||
|
||||
topicData['pin-icon'] = parseInt(topicData.pinned, 10) === 1 ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
|
||||
topicData['deleted-class'] = parseInt(topicData.deleted, 10) === 1 ? 'deleted' : '';
|
||||
topicData['unread-class'] = !(topicInfo.hasread && parseInt(current_user, 10) !== 0) ? 'unread' : '';
|
||||
|
||||
topicData.pinned = parseInt(topicData.pinned, 10) === 1;
|
||||
topicData.locked = parseInt(topicData.locked, 10) === 1;
|
||||
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
||||
topicData.unread = !(topicInfo.hasread && parseInt(current_user, 10) !== 0);
|
||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||
topicData.username = topicInfo.username || 'anonymous';
|
||||
topicData.userslug = topicInfo.userslug || '';
|
||||
topicData.picture = topicInfo.picture || gravatar.url('', {}, true);
|
||||
topicData.categoryIcon = topicInfo.categoryData.icon;
|
||||
topicData.categoryName = topicInfo.categoryData.name;
|
||||
topicData.categorySlug = topicInfo.categoryData.slug;
|
||||
|
||||
topicData.teaser_username = topicInfo.teaserInfo.username || '';
|
||||
topicData.teaser_userslug = topicInfo.teaserInfo.userslug || '';
|
||||
topicData.teaser_userpicture = topicInfo.teaserInfo.picture || gravatar.url('', {}, true);
|
||||
topicData.teaser_pid = topicInfo.teaserInfo.pid;
|
||||
topicData.teaser_timestamp = utils.toISOString(topicInfo.teaserInfo.timestamp);
|
||||
topicData.category = topicInfo.categoryData;
|
||||
topicData.teaser = topicInfo.teaser;
|
||||
|
||||
next(null, topicData);
|
||||
});
|
||||
@@ -851,45 +822,6 @@ var async = require('async'),
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Topics.getTopicForCategoryView = function(tid, uid, callback) {
|
||||
|
||||
function getTopicData(next) {
|
||||
Topics.getTopicDataWithUser(tid, next);
|
||||
}
|
||||
|
||||
function getReadStatus(next) {
|
||||
Topics.hasReadTopic(tid, uid, next);
|
||||
}
|
||||
|
||||
function getTeaser(next) {
|
||||
Topics.getTeaser(tid, next);
|
||||
}
|
||||
|
||||
async.parallel([getTopicData, getReadStatus, getTeaser], function(err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var topicData = results[0],
|
||||
hasRead = results[1],
|
||||
teaser = results[2];
|
||||
|
||||
topicData['pin-icon'] = parseInt(topicData.pinned, 10) === 1 ? 'fa-thumb-tack' : 'none';
|
||||
topicData['lock-icon'] = parseInt(topicData.locked, 10) === 1 ? 'fa-lock' : 'none';
|
||||
topicData['unread-class'] = !(hasRead && parseInt(uid, 10) !== 0) ? 'unread' : '';
|
||||
|
||||
topicData.unread = !(hasRead && parseInt(uid, 10) !== 0);
|
||||
topicData.teaser_username = teaser.username || '';
|
||||
topicData.teaser_userslug = teaser.userslug || '';
|
||||
topicData.userslug = teaser.userslug || '';
|
||||
topicData.teaser_timestamp = utils.toISOString(teaser.timestamp);
|
||||
topicData.teaser_userpicture = teaser.picture;
|
||||
|
||||
callback(null, topicData);
|
||||
});
|
||||
};
|
||||
|
||||
Topics.getAllTopics = function(start, end, callback) {
|
||||
db.getSortedSetRevRange('topics:tid', start, end, function(err, tids) {
|
||||
if(err) {
|
||||
@@ -1026,9 +958,7 @@ var async = require('async'),
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
async.map(tids, function(tid, next) {
|
||||
Topics.getTeaser(tid, next);
|
||||
}, callback);
|
||||
async.map(tids, Topics.getTeaser, callback)
|
||||
};
|
||||
|
||||
Topics.getTeaser = function(tid, callback) {
|
||||
@@ -1037,6 +967,10 @@ var async = require('async'),
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!pid) {
|
||||
return callback(null, null);
|
||||
}
|
||||
|
||||
posts.getPostFields(pid, ['pid', 'uid', 'timestamp'], function(err, postData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
@@ -1052,9 +986,9 @@ var async = require('async'),
|
||||
callback(null, {
|
||||
pid: postData.pid,
|
||||
username: userData.username || 'anonymous',
|
||||
userslug: userData.userslug,
|
||||
userslug: userData.userslug || '',
|
||||
picture: userData.picture || gravatar.url('', {}, true),
|
||||
timestamp: postData.timestamp
|
||||
timestamp: utils.toISOString(postData.timestamp)
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1103,7 +1037,7 @@ var async = require('async'),
|
||||
Topics.isLocked = function(tid, callback) {
|
||||
Topics.getTopicField(tid, 'locked', function(err, locked) {
|
||||
if(err) {
|
||||
return callback(err, null);
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, parseInt(locked, 10) === 1);
|
||||
});
|
||||
@@ -1138,16 +1072,18 @@ var async = require('async'),
|
||||
|
||||
function getUid(pid, next) {
|
||||
posts.getPostField(pid, 'uid', function(err, uid) {
|
||||
if (err)
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
uids[uid] = 1;
|
||||
next(null);
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
async.each(pids, getUid, function(err) {
|
||||
if (err)
|
||||
return callback(err, null);
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
callback(null, Object.keys(uids));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user