mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
anons cant edit after posting #365
This commit is contained in:
@@ -344,8 +344,8 @@ var socket,
|
||||
|
||||
app.createNewPosts = function (data) {
|
||||
if (data.posts[0].uid !== app.uid) {
|
||||
data.posts[0].display_moderator_tools = 'none';
|
||||
}
|
||||
data.posts[0].display_moderator_tools = 'none';
|
||||
}
|
||||
|
||||
var html = templates.prepare(templates['topic'].blocks['posts']).parse(data);
|
||||
translator.translate(html, function(translatedHTML) {
|
||||
|
||||
@@ -548,7 +548,7 @@ define(function() {
|
||||
});
|
||||
|
||||
socket.on('api:post.privileges', function(privileges) {
|
||||
if (privileges.editable) toggle_mod_tools(privileges.pid, true);
|
||||
toggle_mod_tools(privileges.pid, privileges.editable);
|
||||
});
|
||||
|
||||
function adjust_rep(value, pid, uid) {
|
||||
|
||||
@@ -25,7 +25,13 @@ var RDB = require('./redis.js'),
|
||||
}
|
||||
|
||||
PostTools.privileges = function(pid, uid, callback) {
|
||||
//todo: break early if one condition is true
|
||||
if(uid == 0) {
|
||||
callback({
|
||||
editable: false,
|
||||
view_deleted: false
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
function getThreadPrivileges(next) {
|
||||
posts.getPostField(pid, 'tid', function(tid) {
|
||||
|
||||
@@ -304,6 +304,7 @@ var RDB = require('./redis.js'),
|
||||
var socketData = {
|
||||
posts: [postData]
|
||||
};
|
||||
|
||||
io.sockets.in('topic_' + tid).emit('event:new_post', socketData);
|
||||
io.sockets.in('recent_posts').emit('event:new_post', socketData);
|
||||
io.sockets.in('user/' + uid).emit('event:new_post', socketData);
|
||||
|
||||
@@ -541,8 +541,15 @@ module.exports.init = function(io) {
|
||||
});
|
||||
|
||||
socket.on('api:posts.edit', function(data) {
|
||||
|
||||
if (!data.title || data.title.length < topics.minimumTitleLength) {
|
||||
if(!uid) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Can't edit',
|
||||
message: 'Guests can't edit posts!',
|
||||
type: 'warning',
|
||||
timeout: 2000
|
||||
});
|
||||
return;
|
||||
} else if (!data.title || data.title.length < topics.minimumTitleLength) {
|
||||
topics.emitTitleTooShortAlert(socket);
|
||||
return;
|
||||
} else if (!data.content || data.content.length < require('../public/config.json').minimumPostLength) {
|
||||
|
||||
Reference in New Issue
Block a user