mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
Merge branch 'master' of https://github.com/NodeBB/NodeBB
This commit is contained in:
@@ -53,7 +53,7 @@
|
|||||||
"nodebb-plugin-spam-be-gone": "0.4.5",
|
"nodebb-plugin-spam-be-gone": "0.4.5",
|
||||||
"nodebb-rewards-essentials": "0.0.8",
|
"nodebb-rewards-essentials": "0.0.8",
|
||||||
"nodebb-theme-lavender": "3.0.9",
|
"nodebb-theme-lavender": "3.0.9",
|
||||||
"nodebb-theme-persona": "4.0.101",
|
"nodebb-theme-persona": "4.0.102",
|
||||||
"nodebb-theme-vanilla": "5.0.57",
|
"nodebb-theme-vanilla": "5.0.57",
|
||||||
"nodebb-widget-essentials": "2.0.8",
|
"nodebb-widget-essentials": "2.0.8",
|
||||||
"nodemailer": "2.0.0",
|
"nodemailer": "2.0.0",
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ define('forum/topic/postTools', ['share', 'navigator', 'components', 'translator
|
|||||||
return app.alertError(err);
|
return app.alertError(err);
|
||||||
}
|
}
|
||||||
data.posts.display_move_tools = data.posts.display_move_tools && index !== 0;
|
data.posts.display_move_tools = data.posts.display_move_tools && index !== 0;
|
||||||
data.postSharing = data.postSharing.filter(function(share) { return share.activated === true; });
|
|
||||||
|
|
||||||
templates.parse('partials/topic/post-menu-list', data, function(html) {
|
templates.parse('partials/topic/post-menu-list', data, function(html) {
|
||||||
translator.translate(html, function(html) {
|
translator.translate(html, function(html) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ define('forum/topic/posts', [
|
|||||||
post.selfPost = !!app.user.uid && parseInt(post.uid, 10) === parseInt(app.user.uid, 10);
|
post.selfPost = !!app.user.uid && parseInt(post.uid, 10) === parseInt(app.user.uid, 10);
|
||||||
post.display_moderator_tools = post.selfPost || ajaxify.data.privileges.isAdminOrMod;
|
post.display_moderator_tools = post.selfPost || ajaxify.data.privileges.isAdminOrMod;
|
||||||
post.display_move_tools = ajaxify.data.privileges.isAdminOrMod;
|
post.display_move_tools = ajaxify.data.privileges.isAdminOrMod;
|
||||||
post.display_post_menu = post.selfPost || ajaxify.data.privileges.isAdminOrMod || !post.deleted;
|
post.display_post_menu = ajaxify.data.privileges.isAdminOrMod || post.selfPost || ((app.user.uid || ajaxify.data.postSharing.length) && !post.deleted);
|
||||||
});
|
});
|
||||||
|
|
||||||
updatePostCounts(data.posts);
|
updatePostCounts(data.posts);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ topicsController.get = function(req, res, callback) {
|
|||||||
return callback();
|
return callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
topics.modifyPostsByPrivilege(topicData.posts, userPrivileges);
|
topics.modifyPostsByPrivilege(topicData, userPrivileges);
|
||||||
|
|
||||||
plugins.fireHook('filter:controllers.topic.get', {topicData: topicData, uid: req.uid}, next);
|
plugins.fireHook('filter:controllers.topic.get', {topicData: topicData, uid: req.uid}, next);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
|
|
||||||
callback(null, _nids.filter(function(nid, idx) {
|
callback(null, _nids.filter(function(nid, idx) {
|
||||||
return mergeIds.indexOf(sets[idx]) !== -1
|
return mergeIds.indexOf(sets[idx]) !== -1;
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -450,13 +450,14 @@ var async = require('async'),
|
|||||||
});
|
});
|
||||||
var numUsers = usernames.length;
|
var numUsers = usernames.length;
|
||||||
|
|
||||||
var title = S(notifications[modifyIndex].topicTitle).decodeHTMLEntities().s;
|
var title = S(notifications[modifyIndex].topicTitle || '').decodeHTMLEntities().s;
|
||||||
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
var titleEscaped = title.replace(/%/g, '%').replace(/,/g, ',');
|
||||||
|
titleEscaped = titleEscaped ? (', ' + titleEscaped) : '';
|
||||||
|
|
||||||
if (numUsers === 2) {
|
if (numUsers === 2) {
|
||||||
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + ', ' + titleEscaped + ']]';
|
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + titleEscaped + ']]';
|
||||||
} else if (numUsers > 2) {
|
} else if (numUsers > 2) {
|
||||||
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + titleEscaped + ']]';
|
notifications[modifyIndex].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers - 1) + titleEscaped + ']]';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function generateForTopic(req, res, callback) {
|
|||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
topics.modifyPostsByPrivilege(topicData.posts, userPrivileges);
|
topics.modifyPostsByPrivilege(topicData, userPrivileges);
|
||||||
|
|
||||||
var description = topicData.posts.length ? topicData.posts[0].content : '';
|
var description = topicData.posts.length ? topicData.posts[0].content : '';
|
||||||
var image_url = topicData.posts.length ? topicData.posts[0].picture : '';
|
var image_url = topicData.posts.length ? topicData.posts[0].picture : '';
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ var async = require('async');
|
|||||||
|
|
||||||
var social = {};
|
var social = {};
|
||||||
|
|
||||||
|
social.postSharing = null;
|
||||||
|
|
||||||
social.getPostSharing = function(callback) {
|
social.getPostSharing = function(callback) {
|
||||||
|
if (social.postSharing) {
|
||||||
|
return callback(null, social.postSharing);
|
||||||
|
}
|
||||||
|
|
||||||
var networks = [
|
var networks = [
|
||||||
{
|
{
|
||||||
id: "facebook",
|
id: "facebook",
|
||||||
@@ -39,20 +45,41 @@ social.getPostSharing = function(callback) {
|
|||||||
networks[i].activated = (activated.indexOf(network.id) !== -1);
|
networks[i].activated = (activated.indexOf(network.id) !== -1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
social.postSharing = networks;
|
||||||
next(null, networks);
|
next(null, networks);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
social.setActivePostSharingNetworks = function(networkIDs, callback) {
|
social.getActivePostSharing = function(callback) {
|
||||||
db.delete('social:posts.activated', function(err) {
|
social.getPostSharing(function(err, networks) {
|
||||||
if (!networkIDs.length) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
networks = networks.filter(function(network) {
|
||||||
db.setAdd('social:posts.activated', networkIDs, callback);
|
return network && network.activated;
|
||||||
|
});
|
||||||
|
callback(null, networks);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
social.setActivePostSharingNetworks = function(networkIDs, callback) {
|
||||||
|
async.waterfall([
|
||||||
|
function (next) {
|
||||||
|
db.delete('social:posts.activated', next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
if (!networkIDs.length) {
|
||||||
|
return next();
|
||||||
|
}
|
||||||
|
db.setAdd('social:posts.activated', networkIDs, next);
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
social.postSharing = null;
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
], callback);
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = social;
|
module.exports = social;
|
||||||
@@ -178,16 +178,16 @@ SocketGroups.create = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketGroups.delete = function(socket, data, callback) {
|
SocketGroups.delete = function(socket, data, callback) {
|
||||||
if (data.groupName === 'administrators' || data.groupName === 'registered-users') {
|
if (data.groupName === 'administrators' ||
|
||||||
|
data.groupName === 'registered-users' ||
|
||||||
|
data.groupName === 'Global Moderators') {
|
||||||
return callback(new Error('[[error:not-allowed]]'));
|
return callback(new Error('[[error:not-allowed]]'));
|
||||||
}
|
}
|
||||||
|
|
||||||
var tasks = {
|
async.parallel({
|
||||||
isOwner: async.apply(groups.ownership.isOwner, socket.uid, data.groupName),
|
isOwner: async.apply(groups.ownership.isOwner, socket.uid, data.groupName),
|
||||||
isAdmin: async.apply(user.isAdministrator, socket.uid)
|
isAdmin: async.apply(user.isAdministrator, socket.uid)
|
||||||
};
|
}, function(err, checks) {
|
||||||
|
|
||||||
async.parallel(tasks, function(err, checks) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ module.exports = function(SocketPosts) {
|
|||||||
plugins.fireHook('filter:post.tools', {pid: data.pid, uid: socket.uid, tools: []}, next);
|
plugins.fireHook('filter:post.tools', {pid: data.pid, uid: socket.uid, tools: []}, next);
|
||||||
},
|
},
|
||||||
postSharing: function(next) {
|
postSharing: function(next) {
|
||||||
social.getPostSharing(next);
|
social.getActivePostSharing(next);
|
||||||
}
|
}
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ var topics = require('../../topics');
|
|||||||
var privileges = require('../../privileges');
|
var privileges = require('../../privileges');
|
||||||
var meta = require('../../meta');
|
var meta = require('../../meta');
|
||||||
var utils = require('../../../public/src/utils');
|
var utils = require('../../../public/src/utils');
|
||||||
|
var social = require('../../social');
|
||||||
|
|
||||||
module.exports = function(SocketTopics) {
|
module.exports = function(SocketTopics) {
|
||||||
|
|
||||||
@@ -68,6 +69,9 @@ module.exports = function(SocketTopics) {
|
|||||||
},
|
},
|
||||||
posts: function(next) {
|
posts: function(next) {
|
||||||
topics.getTopicPosts(data.tid, set, start, stop, socket.uid, reverse, next);
|
topics.getTopicPosts(data.tid, set, start, stop, socket.uid, reverse, next);
|
||||||
|
},
|
||||||
|
postSharing: function (next) {
|
||||||
|
social.getActivePostSharing(next);
|
||||||
}
|
}
|
||||||
}, function(err, topicData) {
|
}, function(err, topicData) {
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -81,7 +85,7 @@ module.exports = function(SocketTopics) {
|
|||||||
topicData['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
|
topicData['reputation:disabled'] = parseInt(meta.config['reputation:disabled'], 10) === 1;
|
||||||
topicData['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1;
|
topicData['downvote:disabled'] = parseInt(meta.config['downvote:disabled'], 10) === 1;
|
||||||
|
|
||||||
topics.modifyPostsByPrivilege(topicData.posts, results.privileges);
|
topics.modifyPostsByPrivilege(topicData, results.privileges);
|
||||||
callback(null, topicData);
|
callback(null, topicData);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
_ = require('underscore'),
|
var _ = require('underscore');
|
||||||
|
|
||||||
db = require('./database'),
|
var db = require('./database');
|
||||||
posts = require('./posts'),
|
var posts = require('./posts');
|
||||||
utils = require('../public/src/utils'),
|
var utils = require('../public/src/utils');
|
||||||
plugins = require('./plugins'),
|
var plugins = require('./plugins');
|
||||||
user = require('./user'),
|
var user = require('./user');
|
||||||
categories = require('./categories'),
|
var categories = require('./categories');
|
||||||
privileges = require('./privileges');
|
var privileges = require('./privileges');
|
||||||
|
var social = require('./social');
|
||||||
|
|
||||||
(function(Topics) {
|
(function(Topics) {
|
||||||
|
|
||||||
@@ -179,7 +180,8 @@ var async = require('async'),
|
|||||||
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}),
|
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}),
|
||||||
tags: async.apply(Topics.getTopicTagsObjects, topicData.tid),
|
tags: async.apply(Topics.getTopicTagsObjects, topicData.tid),
|
||||||
isFollowing: async.apply(Topics.isFollowing, [topicData.tid], uid),
|
isFollowing: async.apply(Topics.isFollowing, [topicData.tid], uid),
|
||||||
bookmark: async.apply(Topics.getUserBookmark, topicData.tid, uid)
|
bookmark: async.apply(Topics.getUserBookmark, topicData.tid, uid),
|
||||||
|
postSharing: async.apply(social.getActivePostSharing)
|
||||||
}, next);
|
}, next);
|
||||||
},
|
},
|
||||||
function (results, next) {
|
function (results, next) {
|
||||||
@@ -189,6 +191,7 @@ var async = require('async'),
|
|||||||
topicData.tags = results.tags;
|
topicData.tags = results.tags;
|
||||||
topicData.isFollowing = results.isFollowing[0];
|
topicData.isFollowing = results.isFollowing[0];
|
||||||
topicData.bookmark = results.bookmark;
|
topicData.bookmark = results.bookmark;
|
||||||
|
topicData.postSharing = results.postSharing;
|
||||||
|
|
||||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||||
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ module.exports = function(Topics) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
topic.titleRaw = topic.title;
|
topic.titleRaw = topic.title;
|
||||||
topic.title = validator.escape(topic.title);
|
topic.title = validator.escape(String(topic.title));
|
||||||
topic.timestampISO = utils.toISOString(topic.timestamp);
|
topic.timestampISO = utils.toISOString(topic.timestamp);
|
||||||
topic.lastposttimeISO = utils.toISOString(topic.lastposttime);
|
topic.lastposttimeISO = utils.toISOString(topic.lastposttime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async'),
|
var async = require('async');
|
||||||
_ = require('underscore'),
|
var _ = require('underscore');
|
||||||
validator = require('validator'),
|
var validator = require('validator');
|
||||||
|
|
||||||
db = require('../database'),
|
var db = require('../database');
|
||||||
user = require('../user'),
|
var user = require('../user');
|
||||||
favourites = require('../favourites'),
|
var favourites = require('../favourites');
|
||||||
posts = require('../posts'),
|
var posts = require('../posts');
|
||||||
meta = require('../meta');
|
var meta = require('../meta');
|
||||||
|
|
||||||
module.exports = function(Topics) {
|
module.exports = function(Topics) {
|
||||||
|
|
||||||
@@ -138,12 +137,13 @@ module.exports = function(Topics) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.modifyPostsByPrivilege = function(postData, topicPrivileges) {
|
Topics.modifyPostsByPrivilege = function(topicData, topicPrivileges) {
|
||||||
postData.forEach(function(post) {
|
var loggedIn = !!parseInt(topicPrivileges.uid, 10);
|
||||||
|
topicData.posts.forEach(function(post) {
|
||||||
if (post) {
|
if (post) {
|
||||||
post.display_moderator_tools = topicPrivileges.isAdminOrMod || post.selfPost;
|
post.display_moderator_tools = topicPrivileges.isAdminOrMod || post.selfPost;
|
||||||
post.display_move_tools = topicPrivileges.isAdminOrMod && post.index !== 0;
|
post.display_move_tools = topicPrivileges.isAdminOrMod && post.index !== 0;
|
||||||
post.display_post_menu = topicPrivileges.isAdminOrMod || post.selfPost || !post.deleted;
|
post.display_post_menu = topicPrivileges.isAdminOrMod || post.selfPost || ((loggedIn || topicData.postSharing.length) && !post.deleted);
|
||||||
post.ip = topicPrivileges.isAdminOrMod ? post.ip : undefined;
|
post.ip = topicPrivileges.isAdminOrMod ? post.ip : undefined;
|
||||||
|
|
||||||
if (post.deleted && !(topicPrivileges.isAdminOrMod || post.selfPost)) {
|
if (post.deleted && !(topicPrivileges.isAdminOrMod || post.selfPost)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user