v1.18.x
Baris Usakli 6 years ago
commit 06932602ab

@ -70,24 +70,22 @@ function postReply(socket, data, callback) {
], callback);
}
SocketPosts.getRawPost = function (socket, pid, callback) {
async.waterfall([
function (next) {
privileges.posts.can('topics:read', pid, socket.uid, next);
},
function (canRead, next) {
SocketPosts.getRawPost = async (socket, pid) => {
const canRead = await privileges.posts.can('topics:read', pid, socket.uid);
if (!canRead) {
return next(new Error('[[error:no-privileges]]'));
throw new Error('[[error:no-privileges]]');
}
posts.getPostFields(pid, ['content', 'deleted'], next);
},
function (postData, next) {
let postData = await posts.getPostFields(pid, ['content', 'deleted']);
if (postData.deleted) {
return next(new Error('[[error:no-post]]'));
throw new Error('[[error:no-post]]');
}
next(null, postData.content);
},
], callback);
postData = await plugins.fireHook('filter:post.getRawPost', Object.assign(postData, {
pid: pid,
}));
return postData.content;
};
SocketPosts.getTimestampByIndex = function (socket, data, callback) {

Loading…
Cancel
Save