projection to remove salts from post api. Fixes #4

merge-requests/208/head
fatchan 5 years ago
parent 7bafb670bf
commit 50f09d2f83
  1. 12
      db-models/posts.js

@ -22,6 +22,8 @@ module.exports = {
await Promise.all(threads.map(async thread => { await Promise.all(threads.map(async thread => {
const replies = await db.collection(board).find({ const replies = await db.collection(board).find({
'thread': thread._id 'thread': thread._id
}, {
'projection': { 'salt': 0 }
}).sort({ }).sort({
'_id': -1 '_id': -1
}).limit(3).toArray(); }).limit(3).toArray();
@ -38,6 +40,8 @@ module.exports = {
const data = await Promise.all([ const data = await Promise.all([
db.collection(board).findOne({ db.collection(board).findOne({
'_id': id '_id': id
}, {
'projection': { 'salt': 0 } //projection to hide salts
}), }),
module.exports.getThreadPosts(board, id) module.exports.getThreadPosts(board, id)
]) ])
@ -57,6 +61,8 @@ module.exports = {
// all posts within a thread // all posts within a thread
return db.collection(board).find({ return db.collection(board).find({
'thread': id 'thread': id
}, {
'projection': { 'salt': 0 } //projection to hide salts
}).sort({ }).sort({
'_id': 1 '_id': 1
}).toArray(); }).toArray();
@ -68,6 +74,8 @@ module.exports = {
// get all threads for catalog // get all threads for catalog
return db.collection(board).find({ return db.collection(board).find({
'thread': null 'thread': null
}, {
'projection': { 'salt': 0 } //projection to hide salts
}).toArray(); }).toArray();
}, },
@ -77,6 +85,8 @@ module.exports = {
// get a post // get a post
return db.collection(board).findOne({ return db.collection(board).findOne({
'_id': id '_id': id
}, {
'projection': { 'salt': 0 } //projection to hide salts
}); });
}, },
@ -88,6 +98,8 @@ module.exports = {
'_id': { '_id': {
'$in': ids '$in': ids
} }
}, {
'projection': { 'salt': 0 } //projection to hide salts
}).toArray(); }).toArray();
}, },

Loading…
Cancel
Save