Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit 449adfae59

@ -94,9 +94,8 @@ define(['taskbar'], function(taskbar) {
var postContainer = $(composerTemplate[0]);
if(config.imgurClientIDSet) {
if(config.allowFileUploads || config.imgurClientIDSet)
initializeFileReader(post_uuid);
}
var postData = composer.posts[post_uuid],
titleEl = postContainer.find('.title'),

@ -269,6 +269,9 @@
module.setObjectField = function(key, field, value, callback) {
var data = {};
// if there is a '.' in the field name it inserts subdocument in mongo, replace '.'s with \uff0E
if(typeof field !== 'string') {
field = field.toString();
}
field = field.replace(/\./g, '\uff0E');
data[field] = value;
db.collection('objects').update({_key:key}, {$set:data}, {upsert:true, w: 1}, function(err, result) {
@ -318,7 +321,7 @@
var _fields = {};
for(var i=0; i<fields.length; ++i) {
if(typeof fields[i] !== string) {
if(typeof fields[i] !== 'string') {
_fields[fields[i].toString().replace(/\./g, '\uff0E')] = 1;
} else {
_fields[fields[i].replace(/\./g, '\uff0E')] = 1;
@ -363,6 +366,9 @@
module.isObjectField = function(key, field, callback) {
var data = {};
if(typeof field !== 'string') {
field = field.toString();
}
field = field.replace(/\./g, '\uff0E');
data[field] = '';
db.collection('objects').findOne({_key:key}, {fields:data}, function(err, item) {
@ -375,6 +381,9 @@
module.deleteObjectField = function(key, field, callback) {
var data = {};
if(typeof field !== 'string') {
field = field.toString();
}
field = field.replace(/\./g, '\uff0E');
data[field] = "";
db.collection('objects').update({_key:key}, {$unset : data}, function(err, result) {
@ -394,6 +403,9 @@
module.incrObjectFieldBy = function(key, field, value, callback) {
var data = {};
if(typeof field !== 'string') {
field = field.toString();
}
field = field.replace(/\./g, '\uff0E');
data[field] = value;
db.collection('objects').update({_key:key}, {$inc : data}, {upsert:true}, function(err, result) {

@ -152,7 +152,7 @@ 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') {
threadTools.delete(postData.tid, function(err) {
threadTools.delete(postData.tid, uid, function(err) {
if (err) {
winston.error('Could not delete topic (tid: ' + postData.tid + ')', err.stack);
}

@ -360,10 +360,7 @@ var db = require('./database'),
Posts.uploadPostImage = function(image, callback) {
if(!meta.config.imgurClientID) {
return callback('imgurClientID not set', null);
}
if(meta.config.imgurClientID) {
if(!image) {
return callback('invalid image', null);
}
@ -378,6 +375,11 @@ var db = require('./database'),
});
}
});
} else if (meta.config.allowFileUploads) {
Posts.uploadPostFile(image, callback);
} else {
callback('Uploads are disabled!');
}
}
Posts.uploadPostFile = function(file, callback) {

@ -91,7 +91,7 @@ var winston = require('winston'),
}
}
ThreadTools.delete = function(tid, callback) {
ThreadTools.delete = function(tid, uid, callback) {
topics.delete(tid);
db.decrObjectField('global', 'topicCount');
@ -112,7 +112,7 @@ var winston = require('winston'),
}
}
ThreadTools.restore = function(tid, socket, callback) {
ThreadTools.restore = function(tid, uid, callback) {
topics.restore(tid);
db.incrObjectField('global', 'topicCount');
ThreadTools.unlock(tid);

@ -562,7 +562,7 @@ websockets.init = function(io) {
socket.on('api:topic.delete', function(data) {
threadTools.privileges(data.tid, uid, function(err, privileges) {
if (!err && privileges.editable) {
threadTools.delete(data.tid, function(err) {
threadTools.delete(data.tid, uid, function(err) {
if (!err) {
emitTopicPostStats();
socket.emit('api:topic.delete', {
@ -578,7 +578,7 @@ websockets.init = function(io) {
socket.on('api:topic.restore', function(data) {
threadTools.privileges(data.tid, uid, function(err, privileges) {
if (!err && privileges.editable) {
threadTools.restore(data.tid, socket, function(err) {
threadTools.restore(data.tid, uid, function(err) {
emitTopicPostStats();
socket.emit('api:topic.restore', {

Loading…
Cancel
Save