mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: check privileges before exporting post/topic data
This commit is contained in:
@@ -195,11 +195,11 @@ userController.exportProfile = async function (req, res) {
|
|||||||
user.auth.getSessions(targetUid, req.sessionID),
|
user.auth.getSessions(targetUid, req.sessionID),
|
||||||
user.getHistory('user:' + targetUid + ':usernames'),
|
user.getHistory('user:' + targetUid + ':usernames'),
|
||||||
user.getHistory('user:' + targetUid + ':emails'),
|
user.getHistory('user:' + targetUid + ':emails'),
|
||||||
getSetData('uid:' + targetUid + ':bookmarks', 'post:'),
|
getSetData('uid:' + targetUid + ':bookmarks', 'post:', targetUid),
|
||||||
getSetData('uid:' + targetUid + ':followed_tids', 'topic:'),
|
getSetData('uid:' + targetUid + ':followed_tids', 'topic:', targetUid),
|
||||||
getSetData('uid:' + targetUid + ':upvote', 'post:'),
|
getSetData('uid:' + targetUid + ':upvote', 'post:', targetUid),
|
||||||
getSetData('uid:' + targetUid + ':downvote', 'post:'),
|
getSetData('uid:' + targetUid + ':downvote', 'post:', targetUid),
|
||||||
getSetData('following:' + targetUid, 'user:'),
|
getSetData('following:' + targetUid, 'user:', targetUid),
|
||||||
]);
|
]);
|
||||||
delete userData.password;
|
delete userData.password;
|
||||||
const followingData = following.map(u => ({ username: u.username, uid: u.uid }));
|
const followingData = following.map(u => ({ username: u.username, uid: u.uid }));
|
||||||
@@ -239,15 +239,19 @@ async function getRoomMessages(uid, roomId) {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSetData(set, keyPrefix) {
|
async function getSetData(set, keyPrefix, uid) {
|
||||||
let data = [];
|
let data = [];
|
||||||
await batch.processSortedSet(set, async (ids) => {
|
await batch.processSortedSet(set, async (ids) => {
|
||||||
data = data.concat(await db.getObjects(ids.map(mid => keyPrefix + mid)));
|
if (keyPrefix === 'post:') {
|
||||||
|
ids = await privileges.posts.filter('topics:read', ids, uid);
|
||||||
|
} else if (keyPrefix === 'topic:') {
|
||||||
|
ids = await privileges.topics.filterTids('topics:read', ids, uid);
|
||||||
|
}
|
||||||
|
data = data.concat(await db.getObjects(ids.map(id => keyPrefix + id)));
|
||||||
}, { batch: 500 });
|
}, { batch: 500 });
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
require('../promisify')(userController, [
|
require('../promisify')(userController, [
|
||||||
'getCurrentUser', 'getUserByUID', 'getUserByUsername', 'getUserByEmail',
|
'getCurrentUser', 'getUserByUID', 'getUserByUsername', 'getUserByEmail',
|
||||||
'exportPosts', 'exportUploads', 'exportProfile',
|
'exportPosts', 'exportUploads', 'exportProfile',
|
||||||
|
|||||||
Reference in New Issue
Block a user