mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-08 11:21:40 +02:00
added toPid to posts
This commit is contained in:
11
src/posts.js
11
src/posts.js
@@ -20,7 +20,12 @@ var db = require('./database'),
|
||||
(function(Posts) {
|
||||
var customUserInfo = {};
|
||||
|
||||
Posts.create = function(uid, tid, content, callback) {
|
||||
Posts.create = function(data, callback) {
|
||||
var uid = data.uid,
|
||||
tid = data.tid,
|
||||
content = data.content,
|
||||
toPid = data.toPid;
|
||||
|
||||
if (uid === null) {
|
||||
return callback(new Error('invalid-user'), null);
|
||||
}
|
||||
@@ -56,6 +61,10 @@ var db = require('./database'),
|
||||
'deleted': 0
|
||||
};
|
||||
|
||||
if (toPid) {
|
||||
postData['toPid'] = toPid;
|
||||
}
|
||||
|
||||
db.setObject('post:' + pid, postData, function(err) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
|
||||
@@ -14,6 +14,7 @@ var async = require('async'),
|
||||
SocketPosts = {};
|
||||
|
||||
SocketPosts.reply = function(socket, data, callback) {
|
||||
|
||||
if (!socket.uid && !parseInt(meta.config.allowGuestPosting, 10)) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Reply Unsuccessful',
|
||||
@@ -28,7 +29,9 @@ SocketPosts.reply = function(socket, data, callback) {
|
||||
return callback(new Error('invalid data'));
|
||||
}
|
||||
|
||||
topics.reply(data.topic_id, socket.uid, data.content, function(err, postData) {
|
||||
data.uid = socket.uid;
|
||||
|
||||
topics.reply(data, function(err, postData) {
|
||||
if(err) {
|
||||
if (err.message === 'content-too-short') {
|
||||
module.parent.exports.emitContentTooShortAlert(socket);
|
||||
|
||||
@@ -121,7 +121,7 @@ var async = require('async'),
|
||||
Topics.create({uid: uid, title: title, cid: cid, thumb: thumb}, next);
|
||||
},
|
||||
function(tid, next) {
|
||||
Topics.reply(tid, uid, content, next);
|
||||
Topics.reply({uid:uid, tid:tid, content:content}, next);
|
||||
},
|
||||
function(postData, next) {
|
||||
threadTools.toggleFollow(postData.tid, uid);
|
||||
@@ -143,9 +143,13 @@ var async = require('async'),
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.reply = function(tid, uid, content, callback) {
|
||||
var privileges;
|
||||
var postData;
|
||||
Topics.reply = function(data, callback) {
|
||||
var tid = data.topic_id,
|
||||
uid = data.uid,
|
||||
toPid = data.toPid,
|
||||
content = data.content,
|
||||
privileges,
|
||||
postData;
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
@@ -170,7 +174,7 @@ var async = require('async'),
|
||||
return next(new Error('content-too-short'));
|
||||
}
|
||||
|
||||
posts.create(uid, tid, content, next);
|
||||
posts.create({uid:uid, tid:tid, content:content, toPid:toPid}, next);
|
||||
},
|
||||
function(data, next) {
|
||||
postData = data;
|
||||
|
||||
Reference in New Issue
Block a user