From c79d983ad3f72f83739b463f24b7a150a6063d8d Mon Sep 17 00:00:00 2001 From: william Murphy Date: Sun, 17 Nov 2019 19:46:41 -0600 Subject: [PATCH] limit outbox stream to boosts/posts so that collection length can serve as post count; return full actor info to reduce duplicatge requests --- routes/outbox.js | 2 +- routes/user.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/outbox.js b/routes/outbox.js index 0effc41..f1e4c84 100644 --- a/routes/outbox.js +++ b/routes/outbox.js @@ -19,7 +19,7 @@ router.post('/', net.security.auth, net.validators.outboxActivity, function (req router.get('/', function (req, res) { const db = req.app.get('db') db.collection('streams') - .find({ actor: pub.utils.usernameToIRI(req.user) }) + .find({ actor: pub.utils.usernameToIRI(req.user), type: { $in: ['Announce', 'Create'] } }) .sort({ _id: -1 }) .project({ _id: 0, _meta: 0, 'object._id': 0, 'object.@context': 0, 'object._meta': 0 }) .toArray() diff --git a/routes/user.js b/routes/user.js index 9dab8bd..0000481 100644 --- a/routes/user.js +++ b/routes/user.js @@ -15,7 +15,7 @@ router.get('/', net.validators.jsonld, function (req, res) { { $lookup: { from: 'objects', localField: '_id', foreignField: 'id', as: 'actor' } }, // merge joined actor up { $replaceRoot: { newRoot: { $mergeObjects: [{ $arrayElemAt: ['$actor', 0] }, '$$ROOT'] } } }, - { $project: { postCount: 1, preferredUsername: 1 } } + { $project: { _id: 0, _meta: 0, actor: 0 } } ]) .sort({ postCount: -1 }) .limit(Number.parseInt(req.query.n) || 20)