mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
closes #294
This commit is contained in:
@@ -377,17 +377,6 @@
|
|||||||
$(this).fadeIn(250);
|
$(this).fadeIn(250);
|
||||||
});
|
});
|
||||||
|
|
||||||
if(data.uploadedImages && data.uploadedImages.length) {
|
|
||||||
$('#images_'+data.pid).html('');
|
|
||||||
for(var i=0; i< data.uploadedImages.length; ++i) {
|
|
||||||
var img = $('<i class="icon-picture icon-1"></i><a href="' + data.uploadedImages[i].url +'"> '+data.uploadedImages[i].name+'</a><br/>');
|
|
||||||
$('#images_' + data.pid).append(img);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$('#images_'+data.pid).html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('time to recreate images', data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.on('api:posts.favourite', function(data) {
|
socket.on('api:posts.favourite', function(data) {
|
||||||
|
|||||||
@@ -1,35 +1,39 @@
|
|||||||
define(['taskbar'], function(taskbar) {
|
define(['taskbar'], function(taskbar) {
|
||||||
var composer = {
|
var composer = {
|
||||||
initialized: false,
|
initialized: false,
|
||||||
active: undefined,
|
active: undefined,
|
||||||
taskbar: taskbar,
|
taskbar: taskbar,
|
||||||
posts: {},
|
posts: {},
|
||||||
postContainer: undefined,
|
postContainer: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
function createImageLabel(img, postImages) {
|
var uploadsInProgress = [];
|
||||||
var imageLabel = $('<span class="label label-primary">' + img.name +'</span>');
|
|
||||||
var closeButton = $('<button class="close">×</button>');
|
|
||||||
|
|
||||||
closeButton.on('click', function(e) {
|
function createImagePlaceholder(img) {
|
||||||
|
var text = $('.post-window textarea').val(),
|
||||||
|
textarea = $('.post-window textarea'),
|
||||||
|
imgText = "";
|
||||||
|
|
||||||
imageLabel.remove();
|
text += imgText;
|
||||||
var index = postImages.indexOf(img);
|
textarea.val(text + " ");
|
||||||
if(index !== -1) {
|
uploadsInProgress.push(1);
|
||||||
postImages.splice(index, 1);
|
socket.emit("api:posts.uploadImage", img, function(err, data) {
|
||||||
}
|
|
||||||
|
var currentText = textarea.val();
|
||||||
|
imgText = "";
|
||||||
|
|
||||||
|
if(!err)
|
||||||
|
textarea.val(currentText.replace(imgText, ""));
|
||||||
|
else
|
||||||
|
textarea.val(currentText.replace(imgText, ""));
|
||||||
|
uploadsInProgress.pop();
|
||||||
});
|
});
|
||||||
|
|
||||||
imageLabel.append(closeButton);
|
|
||||||
return imageLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadFile(file) {
|
function loadFile(file) {
|
||||||
var reader = new FileReader(),
|
var reader = new FileReader(),
|
||||||
dropDiv = $('.post-window .imagedrop'),
|
dropDiv = $('.post-window .imagedrop'),
|
||||||
imagelist = $('.post-window .imagelist'),
|
uuid = dropDiv.parents('[data-uuid]').attr('data-uuid');
|
||||||
uuid = dropDiv.parents('[data-uuid]').attr('data-uuid'),
|
|
||||||
posts = composer.posts[uuid];
|
|
||||||
|
|
||||||
$(reader).on('loadend', function(e) {
|
$(reader).on('loadend', function(e) {
|
||||||
var bin = this.result;
|
var bin = this.result;
|
||||||
@@ -40,11 +44,8 @@ define(['taskbar'], function(taskbar) {
|
|||||||
data: bin
|
data: bin
|
||||||
};
|
};
|
||||||
|
|
||||||
posts.images.push(img);
|
createImagePlaceholder(img);
|
||||||
|
|
||||||
var imageLabel = createImageLabel(img, posts.images);
|
|
||||||
|
|
||||||
imagelist.append(imageLabel);
|
|
||||||
dropDiv.hide();
|
dropDiv.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -89,7 +90,6 @@ define(['taskbar'], function(taskbar) {
|
|||||||
drop.on('drop', function(e) {
|
drop.on('drop', function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var uuid = drop.parents('[data-uuid]').attr('data-uuid'),
|
var uuid = drop.parents('[data-uuid]').attr('data-uuid'),
|
||||||
posts = composer.posts[uuid],
|
|
||||||
dt = e.dataTransfer,
|
dt = e.dataTransfer,
|
||||||
files = dt.files;
|
files = dt.files;
|
||||||
|
|
||||||
@@ -121,7 +121,6 @@ define(['taskbar'], function(taskbar) {
|
|||||||
'</div>' +
|
'</div>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<textarea tabIndex="2"></textarea>' +
|
'<textarea tabIndex="2"></textarea>' +
|
||||||
'<div class="imagelist"></div>'+
|
|
||||||
'<div class="imagedrop"><div>Drag and Drop Images Here</div></div>'+
|
'<div class="imagedrop"><div>Drag and Drop Images Here</div></div>'+
|
||||||
'<div class="btn-toolbar action-bar">' +
|
'<div class="btn-toolbar action-bar">' +
|
||||||
'<div class="btn-group" style="float: right; margin-right: -8px">' +
|
'<div class="btn-group" style="float: right; margin-right: -8px">' +
|
||||||
@@ -151,8 +150,7 @@ define(['taskbar'], function(taskbar) {
|
|||||||
cid: threadData.cid,
|
cid: threadData.cid,
|
||||||
pid: threadData.pid,
|
pid: threadData.pid,
|
||||||
title: threadData.title || '',
|
title: threadData.title || '',
|
||||||
body: threadData.body || '',
|
body: threadData.body || ''
|
||||||
images: threadData.uploadedImages || []
|
|
||||||
};
|
};
|
||||||
composer.load(uuid);
|
composer.load(uuid);
|
||||||
} else {
|
} else {
|
||||||
@@ -265,18 +263,6 @@ define(['taskbar'], function(taskbar) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPostImages(images) {
|
|
||||||
var imagelist = $(composer.postContainer).find('.imagelist');
|
|
||||||
imagelist.empty();
|
|
||||||
|
|
||||||
if(images && images.length) {
|
|
||||||
for(var i=0; i<images.length; ++i) {
|
|
||||||
var imageLabel = createImageLabel(images[i], images);
|
|
||||||
imagelist.append(imageLabel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
composer.load = function(post_uuid) {
|
composer.load = function(post_uuid) {
|
||||||
var post_data = composer.posts[post_uuid],
|
var post_data = composer.posts[post_uuid],
|
||||||
titleEl = composer.postContainer.querySelector('input'),
|
titleEl = composer.postContainer.querySelector('input'),
|
||||||
@@ -299,7 +285,6 @@ define(['taskbar'], function(taskbar) {
|
|||||||
}
|
}
|
||||||
bodyEl.value = post_data.body;
|
bodyEl.value = post_data.body;
|
||||||
|
|
||||||
createPostImages(post_data.images);
|
|
||||||
|
|
||||||
// Direct user focus to the correct element
|
// Direct user focus to the correct element
|
||||||
if ((parseInt(post_data.tid) || parseInt(post_data.pid)) > 0) {
|
if ((parseInt(post_data.tid) || parseInt(post_data.pid)) > 0) {
|
||||||
@@ -334,6 +319,16 @@ define(['taskbar'], function(taskbar) {
|
|||||||
titleEl.value = titleEl.value.trim();
|
titleEl.value = titleEl.value.trim();
|
||||||
bodyEl.value = bodyEl.value.trim();
|
bodyEl.value = bodyEl.value.trim();
|
||||||
|
|
||||||
|
if(uploadsInProgress.length) {
|
||||||
|
return app.alert({
|
||||||
|
type: 'warning',
|
||||||
|
timeout: 2000,
|
||||||
|
title: 'Still uploading',
|
||||||
|
message: "Please wait for uploads to complete.",
|
||||||
|
alert_id: 'post_error'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (titleEl.value.length < config.minimumTitleLength) {
|
if (titleEl.value.length < config.minimumTitleLength) {
|
||||||
return app.alert({
|
return app.alert({
|
||||||
type: 'danger',
|
type: 'danger',
|
||||||
@@ -359,21 +354,18 @@ define(['taskbar'], function(taskbar) {
|
|||||||
socket.emit('api:topics.post', {
|
socket.emit('api:topics.post', {
|
||||||
'title' : titleEl.value,
|
'title' : titleEl.value,
|
||||||
'content' : bodyEl.value,
|
'content' : bodyEl.value,
|
||||||
'category_id' : postData.cid,
|
'category_id' : postData.cid
|
||||||
images: composer.posts[post_uuid].images
|
|
||||||
});
|
});
|
||||||
} else if (parseInt(postData.tid) > 0) {
|
} else if (parseInt(postData.tid) > 0) {
|
||||||
socket.emit('api:posts.reply', {
|
socket.emit('api:posts.reply', {
|
||||||
'topic_id' : postData.tid,
|
'topic_id' : postData.tid,
|
||||||
'content' : bodyEl.value,
|
'content' : bodyEl.value
|
||||||
images: composer.posts[post_uuid].images
|
|
||||||
});
|
});
|
||||||
} else if (parseInt(postData.pid) > 0) {
|
} else if (parseInt(postData.pid) > 0) {
|
||||||
socket.emit('api:posts.edit', {
|
socket.emit('api:posts.edit', {
|
||||||
pid: postData.pid,
|
pid: postData.pid,
|
||||||
content: bodyEl.value,
|
content: bodyEl.value,
|
||||||
title: titleEl.value,
|
title: titleEl.value
|
||||||
images: composer.posts[post_uuid].images
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,7 +375,6 @@ define(['taskbar'], function(taskbar) {
|
|||||||
composer.discard = function(post_uuid) {
|
composer.discard = function(post_uuid) {
|
||||||
if (composer.posts[post_uuid]) {
|
if (composer.posts[post_uuid]) {
|
||||||
$(composer.postContainer).find('.imagedrop').hide();
|
$(composer.postContainer).find('.imagedrop').hide();
|
||||||
$(composer.postContainer).find('.imagelist').empty();
|
|
||||||
delete composer.posts[post_uuid];
|
delete composer.posts[post_uuid];
|
||||||
composer.minimize();
|
composer.minimize();
|
||||||
taskbar.discard('composer', post_uuid);
|
taskbar.discard('composer', post_uuid);
|
||||||
|
|||||||
@@ -56,11 +56,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
<div id="content_{main_posts.pid}" class="post-content">{main_posts.content}</div>
|
||||||
<div id="images_{main_posts.pid}" class="post-images">
|
|
||||||
<!-- BEGIN uploadedImages -->
|
|
||||||
<i class="icon-picture icon-1"></i><a href="{main_posts.uploadedImages.url}"> {main_posts.uploadedImages.name}</a><br/>
|
|
||||||
<!-- END uploadedImages -->
|
|
||||||
</div>
|
|
||||||
<div class="post-signature">{main_posts.signature}</div>
|
<div class="post-signature">{main_posts.signature}</div>
|
||||||
<div class="profile-block">
|
<div class="profile-block">
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
@@ -116,11 +111,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
|
<div id="content_{posts.pid}" class="post-content">{posts.content}</div>
|
||||||
<div id="images_{posts.pid}" class="post-images">
|
|
||||||
<!-- BEGIN uploadedImages -->
|
|
||||||
<i class="icon-picture icon-1"></i><a href="{posts.uploadedImages.url}"> {posts.uploadedImages.name}</a><br/>
|
|
||||||
<!-- END uploadedImages -->
|
|
||||||
</div>
|
|
||||||
<div class="post-signature">{posts.signature}</div>
|
<div class="post-signature">{posts.signature}</div>
|
||||||
<div class="profile-block">
|
<div class="profile-block">
|
||||||
<span class="pull-right">
|
<span class="pull-right">
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
PostTools.edit = function(uid, pid, title, content, images) {
|
PostTools.edit = function(uid, pid, title, content) {
|
||||||
var success = function() {
|
var success = function() {
|
||||||
posts.setPostField(pid, 'content', content);
|
posts.setPostField(pid, 'content', content);
|
||||||
posts.setPostField(pid, 'edited', Date.now());
|
posts.setPostField(pid, 'edited', Date.now());
|
||||||
@@ -67,11 +67,6 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function(next) {
|
|
||||||
posts.uploadPostImages(pid, images, function(err, uploadedImages) {
|
|
||||||
next(err, uploadedImages);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
function(next) {
|
function(next) {
|
||||||
posts.getPostField(pid, 'tid', function(tid) {
|
posts.getPostField(pid, 'tid', function(tid) {
|
||||||
PostTools.isMain(pid, tid, function(isMainPost) {
|
PostTools.isMain(pid, tid, function(isMainPost) {
|
||||||
@@ -90,12 +85,12 @@ var RDB = require('./redis.js'),
|
|||||||
PostTools.toHTML(content, next);
|
PostTools.toHTML(content, next);
|
||||||
}
|
}
|
||||||
], function(err, results) {
|
], function(err, results) {
|
||||||
io.sockets.in('topic_' + results[1].tid).emit('event:post_edited', {
|
console.log("TEEEST");
|
||||||
|
io.sockets.in('topic_' + results[0].tid).emit('event:post_edited', {
|
||||||
pid: pid,
|
pid: pid,
|
||||||
title: title,
|
title: title,
|
||||||
isMainPost: results[1].isMainPost,
|
isMainPost: results[0].isMainPost,
|
||||||
content: results[2],
|
content: results[1]
|
||||||
uploadedImages:results[0]
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
74
src/posts.js
74
src/posts.js
@@ -166,17 +166,6 @@ var RDB = require('./redis.js'),
|
|||||||
postData['edited-class'] = postData.editor !== '' ? '' : 'none';
|
postData['edited-class'] = postData.editor !== '' ? '' : 'none';
|
||||||
postData['relativeEditTime'] = postData.edited !== '0' ? utils.relativeTime(postData.edited) : '';
|
postData['relativeEditTime'] = postData.edited !== '0' ? utils.relativeTime(postData.edited) : '';
|
||||||
|
|
||||||
if(postData.uploadedImages) {
|
|
||||||
try {
|
|
||||||
postData.uploadedImages = JSON.parse(postData.uploadedImages);
|
|
||||||
} catch(err) {
|
|
||||||
postData.uploadedImages = [];
|
|
||||||
winston.err(err);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
postData.uploadedImages = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
postTools.toHTML(postData.content, function(err, content) {
|
postTools.toHTML(postData.content, function(err, content) {
|
||||||
postData.content = content;
|
postData.content = content;
|
||||||
posts.push(postData);
|
posts.push(postData);
|
||||||
@@ -226,7 +215,7 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Posts.reply = function(tid, uid, content, images, callback) {
|
Posts.reply = function(tid, uid, content, callback) {
|
||||||
if(content) {
|
if(content) {
|
||||||
content = content.trim();
|
content = content.trim();
|
||||||
}
|
}
|
||||||
@@ -242,7 +231,7 @@ var RDB = require('./redis.js'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Posts.create(uid, tid, content, images, function(postData) {
|
Posts.create(uid, tid, content, function(postData) {
|
||||||
if (postData) {
|
if (postData) {
|
||||||
|
|
||||||
topics.markUnRead(tid);
|
topics.markUnRead(tid);
|
||||||
@@ -270,7 +259,7 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Posts.create = function(uid, tid, content, images, callback) {
|
Posts.create = function(uid, tid, content, callback) {
|
||||||
if (uid === null) {
|
if (uid === null) {
|
||||||
callback(null);
|
callback(null);
|
||||||
return;
|
return;
|
||||||
@@ -293,7 +282,6 @@ var RDB = require('./redis.js'),
|
|||||||
'editor': '',
|
'editor': '',
|
||||||
'edited': 0,
|
'edited': 0,
|
||||||
'deleted': 0,
|
'deleted': 0,
|
||||||
'uploadedImages': '[]',
|
|
||||||
'fav_button_class': '',
|
'fav_button_class': '',
|
||||||
'fav_star_class': 'icon-star-empty',
|
'fav_star_class': 'icon-star-empty',
|
||||||
'show_banned': 'hide',
|
'show_banned': 'hide',
|
||||||
@@ -331,16 +319,6 @@ var RDB = require('./redis.js'),
|
|||||||
user.onNewPostMade(uid, tid, pid, timestamp);
|
user.onNewPostMade(uid, tid, pid, timestamp);
|
||||||
|
|
||||||
async.parallel({
|
async.parallel({
|
||||||
uploadedImages: function(next) {
|
|
||||||
Posts.uploadPostImages(postData.pid, images, function(err, uploadedImages) {
|
|
||||||
if(err) {
|
|
||||||
winston.error('Uploading images failed!', err.stack);
|
|
||||||
next(null, []);
|
|
||||||
} else {
|
|
||||||
next(null, uploadedImages);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
content: function(next) {
|
content: function(next) {
|
||||||
plugins.fireHook('filter:post.get', postData, function(postData) {
|
plugins.fireHook('filter:post.get', postData, function(postData) {
|
||||||
postTools.toHTML(postData.content, function(err, content) {
|
postTools.toHTML(postData.content, function(err, content) {
|
||||||
@@ -349,7 +327,6 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
postData.uploadedImages = results.uploadedImages;
|
|
||||||
postData.content = results.content;
|
postData.content = results.content;
|
||||||
callback(postData);
|
callback(postData);
|
||||||
});
|
});
|
||||||
@@ -365,42 +342,25 @@ var RDB = require('./redis.js'),
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Posts.uploadPostImages = function(pid, images, callback) {
|
Posts.uploadPostImage = function(image, callback) {
|
||||||
var imgur = require('./imgur');
|
var imgur = require('./imgur');
|
||||||
imgur.setClientID(meta.config.imgurClientID);
|
imgur.setClientID(meta.config.imgurClientID);
|
||||||
|
|
||||||
if(!images)
|
if(!image)
|
||||||
return callback(null, []);
|
return callback('invalid image', null);
|
||||||
|
|
||||||
var uploadedImages = images.filter(function(image) { return !!image.url; });
|
imgur.upload(image.data, 'base64', function(err, data) {
|
||||||
|
if(err) {
|
||||||
function uploadImage(image, next) {
|
callback('Can\'t upload image!', null);
|
||||||
if(!image.data)
|
|
||||||
return next(null);
|
|
||||||
|
|
||||||
imgur.upload(image.data, 'base64', function(err, data) {
|
|
||||||
if(err) {
|
|
||||||
next(err);
|
|
||||||
} else {
|
|
||||||
if(data.success) {
|
|
||||||
var img= {url:data.data.link, name:image.name};
|
|
||||||
uploadedImages.push(img);
|
|
||||||
next(null);
|
|
||||||
} else {
|
|
||||||
winston.error('Can\'t upload image, did you set imgurClientID?');
|
|
||||||
next(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async.each(images, uploadImage, function(err) {
|
|
||||||
if(!err) {
|
|
||||||
Posts.setPostField(pid, 'uploadedImages', JSON.stringify(uploadedImages));
|
|
||||||
callback(null, uploadedImages);
|
|
||||||
} else {
|
} else {
|
||||||
console.log(err);
|
if(data.success) {
|
||||||
callback(err, null);
|
var img= {url:data.data.link, name:image.name};
|
||||||
|
|
||||||
|
callback(null, img);
|
||||||
|
} else {
|
||||||
|
winston.error('Can\'t upload image, did you set imgurClientID?');
|
||||||
|
callback("upload error", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ var RDB = require('./redis.js')
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Topics.post = function(uid, title, content, category_id, images, callback) {
|
Topics.post = function(uid, title, content, category_id, callback) {
|
||||||
if (!category_id)
|
if (!category_id)
|
||||||
throw new Error('Attempted to post without a category_id');
|
throw new Error('Attempted to post without a category_id');
|
||||||
|
|
||||||
@@ -678,7 +678,7 @@ var RDB = require('./redis.js')
|
|||||||
|
|
||||||
feed.updateCategory(category_id);
|
feed.updateCategory(category_id);
|
||||||
|
|
||||||
posts.create(uid, tid, content, images, function(postData) {
|
posts.create(uid, tid, content, function(postData) {
|
||||||
if (postData) {
|
if (postData) {
|
||||||
|
|
||||||
// Auto-subscribe the post creator to the newly created topic
|
// Auto-subscribe the post creator to the newly created topic
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
|
|
||||||
socket.on('api:topics.post', function(data) {
|
socket.on('api:topics.post', function(data) {
|
||||||
|
|
||||||
topics.post(uid, data.title, data.content, data.category_id, data.images, function(err, result) {
|
topics.post(uid, data.title, data.content, data.category_id, function(err, result) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if(err.message === 'not-logged-in') {
|
if(err.message === 'not-logged-in') {
|
||||||
socket.emit('event:alert', {
|
socket.emit('event:alert', {
|
||||||
@@ -379,7 +379,7 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
posts.reply(data.topic_id, uid, data.content, data.images, function(err, result) {
|
posts.reply(data.topic_id, uid, data.content, function(err, result) {
|
||||||
if(err) {
|
if(err) {
|
||||||
if(err.message === 'content-too-short') {
|
if(err.message === 'content-too-short') {
|
||||||
posts.emitContentTooShortAlert(socket);
|
posts.emitContentTooShortAlert(socket);
|
||||||
@@ -477,6 +477,10 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
socket.on('api:posts.uploadImage', function(data, callback) {
|
||||||
|
posts.uploadPostImage(data, callback);
|
||||||
|
});
|
||||||
|
|
||||||
socket.on('api:posts.getRawPost', function(data) {
|
socket.on('api:posts.getRawPost', function(data) {
|
||||||
posts.getPostField(data.pid, 'content', function(raw) {
|
posts.getPostField(data.pid, 'content', function(raw) {
|
||||||
socket.emit('api:posts.getRawPost', { post: raw });
|
socket.emit('api:posts.getRawPost', { post: raw });
|
||||||
@@ -623,14 +627,7 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
|
|
||||||
async.parallel([
|
async.parallel([
|
||||||
function(next) {
|
function(next) {
|
||||||
posts.getPostFields(data.pid, ['content', 'uploadedImages'], function(raw) {
|
posts.getPostFields(data.pid, ['content'], function(raw) {
|
||||||
try {
|
|
||||||
raw.uploadedImages = JSON.parse(raw.uploadedImages);
|
|
||||||
} catch(e) {
|
|
||||||
winston.err(e);
|
|
||||||
raw.uploadedImages = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
next(null, raw);
|
next(null, raw);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -643,8 +640,7 @@ var SocketIO = require('socket.io').listen(global.server, {
|
|||||||
socket.emit('api:composer.push', {
|
socket.emit('api:composer.push', {
|
||||||
title: results[1],
|
title: results[1],
|
||||||
pid: data.pid,
|
pid: data.pid,
|
||||||
body: results[0].content,
|
body: results[0].content
|
||||||
uploadedImages: results[0].uploadedImages
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user