limit outbox stream to boosts/posts so that collection length can serve as post count; return full actor info to reduce duplicatge requests
This commit is contained in:
parent
c4946c3621
commit
c79d983ad3
2 changed files with 2 additions and 2 deletions
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue