Skip to content

Node.js based forum software built for the modern web

feat: add vote status to getPostData API call

Julian Lameafe76debb5c
diff --git a/src/controllers/api.js b/src/controllers/api.js
index 746f67184f..8649259b2b 100644
--- a/src/controllers/api.js
+++ b/src/controllers/api.js
@@ -133,14 +133,16 @@ apiController.getPostData = function (pid, uid, callback) {
post: function (next) {
posts.getPostData(pid, next);
},
+ voted: async.apply(posts.hasVoted, pid, uid),
}, function (err, results) {
if (err || !results.post) {
return callback(err);
}
var post = results.post;
- var privileges = results.privileges[0];
+ Object.assign(post, results.voted);
+ var privileges = results.privileges[0];
if (!privileges.read || !privileges['topics:read']) {
return callback();
}