Limit the parallelism of AP object processing (#4193)
This commit is contained in:
parent
1675c473d4
commit
757312ba52
2 changed files with 10 additions and 4 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import * as mongo from 'mongodb';
|
||||
import * as promiseLimit from 'promise-limit';
|
||||
import { toUnicode } from 'punycode';
|
||||
|
||||
import config from '../../../config';
|
||||
|
|
@ -21,7 +22,7 @@ import { ITag, extractHashtags } from './tag';
|
|||
import Following from '../../../models/following';
|
||||
import { IIdentifier } from './identifier';
|
||||
import { apLogger } from '../logger';
|
||||
|
||||
import { INote } from '../../../models/note';
|
||||
const logger = apLogger;
|
||||
|
||||
/**
|
||||
|
|
@ -494,10 +495,11 @@ export async function updateFeatured(userId: mongo.ObjectID) {
|
|||
if (!Array.isArray(items)) throw new Error(`Collection items is not an array`);
|
||||
|
||||
// Resolve and regist Notes
|
||||
const limit = promiseLimit(2);
|
||||
const featuredNotes = await Promise.all(items
|
||||
.filter(item => item.type === 'Note')
|
||||
.slice(0, 5)
|
||||
.map(item => resolveNote(item, resolver)));
|
||||
.map(item => limit(() => resolveNote(item, resolver)) as Promise<INote>));
|
||||
|
||||
await User.update({ _id: user._id }, {
|
||||
$set: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue