|
|
@ -364,6 +364,13 @@ module.exports.init = function(io) {
|
|
|
|
posts.emitContentTooShortAlert(socket);
|
|
|
|
posts.emitContentTooShortAlert(socket);
|
|
|
|
} else if (err.message === 'too-many-posts') {
|
|
|
|
} else if (err.message === 'too-many-posts') {
|
|
|
|
posts.emitTooManyPostsAlert(socket);
|
|
|
|
posts.emitTooManyPostsAlert(socket);
|
|
|
|
|
|
|
|
} else if (err.message === 'no-privileges') {
|
|
|
|
|
|
|
|
socket.emit('event:alert', {
|
|
|
|
|
|
|
|
title: 'Unable to post',
|
|
|
|
|
|
|
|
message: 'You do not have posting privileges in this category.',
|
|
|
|
|
|
|
|
type: 'danger',
|
|
|
|
|
|
|
|
timeout: 7500
|
|
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
socket.emit('event:alert', {
|
|
|
|
socket.emit('event:alert', {
|
|
|
|
title: 'Error',
|
|
|
|
title: 'Error',
|
|
|
@ -423,7 +430,6 @@ module.exports.init = function(io) {
|
|
|
|
|
|
|
|
|
|
|
|
posts.reply(data.topic_id, uid, data.content, function(err, postData) {
|
|
|
|
posts.reply(data.topic_id, uid, data.content, function(err, postData) {
|
|
|
|
if(err) {
|
|
|
|
if(err) {
|
|
|
|
|
|
|
|
|
|
|
|
if (err.message === 'content-too-short') {
|
|
|
|
if (err.message === 'content-too-short') {
|
|
|
|
posts.emitContentTooShortAlert(socket);
|
|
|
|
posts.emitContentTooShortAlert(socket);
|
|
|
|
} else if (err.message === 'too-many-posts') {
|
|
|
|
} else if (err.message === 'too-many-posts') {
|
|
|
@ -435,6 +441,13 @@ module.exports.init = function(io) {
|
|
|
|
type: 'warning',
|
|
|
|
type: 'warning',
|
|
|
|
timeout: 2000
|
|
|
|
timeout: 2000
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
} else if (err.message === 'no-privileges') {
|
|
|
|
|
|
|
|
socket.emit('event:alert', {
|
|
|
|
|
|
|
|
title: 'Unable to post',
|
|
|
|
|
|
|
|
message: 'You do not have posting privileges in this category.',
|
|
|
|
|
|
|
|
type: 'danger',
|
|
|
|
|
|
|
|
timeout: 7500
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -495,8 +508,8 @@ module.exports.init = function(io) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.delete', function(data) {
|
|
|
|
socket.on('api:topic.delete', function(data) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(privileges) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(err, privileges) {
|
|
|
|
if (privileges.editable) {
|
|
|
|
if (!err && privileges.editable) {
|
|
|
|
threadTools.delete(data.tid, function(err) {
|
|
|
|
threadTools.delete(data.tid, function(err) {
|
|
|
|
if (!err) {
|
|
|
|
if (!err) {
|
|
|
|
emitTopicPostStats();
|
|
|
|
emitTopicPostStats();
|
|
|
@ -511,8 +524,8 @@ module.exports.init = function(io) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.restore', function(data) {
|
|
|
|
socket.on('api:topic.restore', function(data) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(privileges) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(err, privileges) {
|
|
|
|
if (privileges.editable) {
|
|
|
|
if (!err && privileges.editable) {
|
|
|
|
threadTools.restore(data.tid, socket, function(err) {
|
|
|
|
threadTools.restore(data.tid, socket, function(err) {
|
|
|
|
emitTopicPostStats();
|
|
|
|
emitTopicPostStats();
|
|
|
|
|
|
|
|
|
|
|
@ -526,32 +539,32 @@ module.exports.init = function(io) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.lock', function(data) {
|
|
|
|
socket.on('api:topic.lock', function(data) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(privileges) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(err, privileges) {
|
|
|
|
if (privileges.editable) {
|
|
|
|
if (!err && privileges.editable) {
|
|
|
|
threadTools.lock(data.tid, socket);
|
|
|
|
threadTools.lock(data.tid, socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.unlock', function(data) {
|
|
|
|
socket.on('api:topic.unlock', function(data) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(privileges) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(err, privileges) {
|
|
|
|
if (privileges.editable) {
|
|
|
|
if (!err && privileges.editable) {
|
|
|
|
threadTools.unlock(data.tid, socket);
|
|
|
|
threadTools.unlock(data.tid, socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.pin', function(data) {
|
|
|
|
socket.on('api:topic.pin', function(data) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(privileges) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(err, privileges) {
|
|
|
|
if (privileges.editable) {
|
|
|
|
if (!err && privileges.editable) {
|
|
|
|
threadTools.pin(data.tid, socket);
|
|
|
|
threadTools.pin(data.tid, socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
socket.on('api:topic.unpin', function(data) {
|
|
|
|
socket.on('api:topic.unpin', function(data) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(privileges) {
|
|
|
|
threadTools.privileges(data.tid, uid, function(err, privileges) {
|
|
|
|
if (privileges.editable) {
|
|
|
|
if (!err && privileges.editable) {
|
|
|
|
threadTools.unpin(data.tid, socket);
|
|
|
|
threadTools.unpin(data.tid, socket);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|