|
|
|
@ -1,8 +1,19 @@
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
var db = require('./database'),
|
|
|
|
|
var async = require('async'),
|
|
|
|
|
path = require('path'),
|
|
|
|
|
fs = require('fs'),
|
|
|
|
|
nconf = require('nconf'),
|
|
|
|
|
validator = require('validator'),
|
|
|
|
|
winston = require('winston'),
|
|
|
|
|
gravatar = require('gravatar'),
|
|
|
|
|
S = require('string'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db = require('./database'),
|
|
|
|
|
utils = require('./../public/src/utils'),
|
|
|
|
|
user = require('./user'),
|
|
|
|
|
groups = require('./groups'),
|
|
|
|
|
topics = require('./topics'),
|
|
|
|
|
favourites = require('./favourites'),
|
|
|
|
|
postTools = require('./postTools'),
|
|
|
|
@ -10,20 +21,9 @@ var db = require('./database'),
|
|
|
|
|
categories = require('./categories'),
|
|
|
|
|
plugins = require('./plugins'),
|
|
|
|
|
meta = require('./meta'),
|
|
|
|
|
emitter = require('./emitter'),
|
|
|
|
|
|
|
|
|
|
async = require('async'),
|
|
|
|
|
path = require('path'),
|
|
|
|
|
fs = require('fs'),
|
|
|
|
|
nconf = require('nconf'),
|
|
|
|
|
validator = require('validator'),
|
|
|
|
|
winston = require('winston'),
|
|
|
|
|
gravatar = require('gravatar'),
|
|
|
|
|
S = require('string');
|
|
|
|
|
emitter = require('./emitter');
|
|
|
|
|
|
|
|
|
|
(function(Posts) {
|
|
|
|
|
var customUserInfo = {};
|
|
|
|
|
|
|
|
|
|
require('./posts/delete')(Posts);
|
|
|
|
|
|
|
|
|
|
Posts.create = function(data, callback) {
|
|
|
|
@ -188,13 +188,13 @@ var db = require('./database'),
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Posts.addUserInfoToPost = function(post, callback) {
|
|
|
|
|
Posts.getUserInfoForPost = function(post, callback) {
|
|
|
|
|
user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post.user = {
|
|
|
|
|
var userInfo = {
|
|
|
|
|
username: userData.username || '[[global:guest]]',
|
|
|
|
|
userslug: userData.userslug || '',
|
|
|
|
|
reputation: userData.reputation || 0,
|
|
|
|
@ -203,24 +203,12 @@ var db = require('./database'),
|
|
|
|
|
picture: userData.picture || user.createGravatarURLFromEmail('')
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (var info in customUserInfo) {
|
|
|
|
|
if (customUserInfo.hasOwnProperty(info)) {
|
|
|
|
|
post.user[info] = userData[info] || customUserInfo[info];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.parallel({
|
|
|
|
|
signature: function(next) {
|
|
|
|
|
if (parseInt(meta.config.disableSignatures, 10) !== 1) {
|
|
|
|
|
return postTools.parseSignature(userData.signature, next);
|
|
|
|
|
}
|
|
|
|
|
next();
|
|
|
|
|
},
|
|
|
|
|
editor: function(next) {
|
|
|
|
|
if (!post.editor) {
|
|
|
|
|
if (parseInt(meta.config.disableSignatures, 10) === 1) {
|
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
user.getUserFields(post.editor, ['username', 'userslug'], next);
|
|
|
|
|
postTools.parseSignature(userData.signature, next);
|
|
|
|
|
},
|
|
|
|
|
customProfileInfo: function(next) {
|
|
|
|
|
plugins.fireHook('filter:posts.custom_profile_info', {profile: [], uid: post.uid, pid: post.pid}, next);
|
|
|
|
@ -229,12 +217,10 @@ var db = require('./database'),
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post.user.signature = results.signature;
|
|
|
|
|
post.editor = results.editor;
|
|
|
|
|
post.custom_profile_info = results.profile;
|
|
|
|
|
|
|
|
|
|
callback(null, post);
|
|
|
|
|
userInfo.signature = results.signature;
|
|
|
|
|
userInfo.custom_profile_info = results.custom_profile_info;
|
|
|
|
|
userInfo.groups = results.groups;
|
|
|
|
|
callback(null, userInfo);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|