Fix forkbomb 2
also in extractApMentions and parseAudience Co-authored-by: mei23 <m@m544.net>
This commit is contained in:
parent
9a32c6bcf7
commit
14221e78b7
|
@ -6,7 +6,7 @@ import type { Config } from '@/config.js';
|
||||||
import { toArray, unique } from '@/misc/prelude/array.js';
|
import { toArray, unique } from '@/misc/prelude/array.js';
|
||||||
import type { CacheableUser } from '@/models/entities/User.js';
|
import type { CacheableUser } from '@/models/entities/User.js';
|
||||||
import { isMention } from '../type.js';
|
import { isMention } from '../type.js';
|
||||||
import { ApResolverService } from '../ApResolverService.js';
|
import { ApResolverService, Resolver } from '../ApResolverService.js';
|
||||||
import { ApPersonService } from './ApPersonService.js';
|
import { ApPersonService } from './ApPersonService.js';
|
||||||
import type { IObject, IApMention } from '../type.js';
|
import type { IObject, IApMention } from '../type.js';
|
||||||
|
|
||||||
|
@ -21,11 +21,9 @@ export class ApMentionService {
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async extractApMentions(tags: IObject | IObject[] | null | undefined) {
|
public async extractApMentions(tags: IObject | IObject[] | null | undefined, resolver: Resolver) {
|
||||||
const hrefs = unique(this.extractApMentionObjects(tags).map(x => x.href as string));
|
const hrefs = unique(this.extractApMentionObjects(tags).map(x => x.href as string));
|
||||||
|
|
||||||
const resolver = this.apResolverService.createResolver();
|
|
||||||
|
|
||||||
const limit = promiseLimit<CacheableUser | null>(2);
|
const limit = promiseLimit<CacheableUser | null>(2);
|
||||||
const mentionedUsers = (await Promise.all(
|
const mentionedUsers = (await Promise.all(
|
||||||
hrefs.map(x => limit(() => this.apPersonService.resolvePerson(x, resolver).catch(() => null))),
|
hrefs.map(x => limit(() => this.apPersonService.resolvePerson(x, resolver).catch(() => null))),
|
||||||
|
|
|
@ -140,7 +140,7 @@ export class ApNoteService {
|
||||||
throw new Error('actor has been suspended');
|
throw new Error('actor has been suspended');
|
||||||
}
|
}
|
||||||
|
|
||||||
const noteAudience = await this.apAudienceService.parseAudience(actor, note.to, note.cc);
|
const noteAudience = await this.apAudienceService.parseAudience(actor, note.to, note.cc, resolver);
|
||||||
let visibility = noteAudience.visibility;
|
let visibility = noteAudience.visibility;
|
||||||
const visibleUsers = noteAudience.visibleUsers;
|
const visibleUsers = noteAudience.visibleUsers;
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ export class ApNoteService {
|
||||||
|
|
||||||
let isMessaging = note._misskey_talk && visibility === 'specified';
|
let isMessaging = note._misskey_talk && visibility === 'specified';
|
||||||
|
|
||||||
const apMentions = await this.apMentionService.extractApMentions(note.tag);
|
const apMentions = await this.apMentionService.extractApMentions(note.tag, resolver);
|
||||||
const apHashtags = await extractApHashtags(note.tag);
|
const apHashtags = await extractApHashtags(note.tag);
|
||||||
|
|
||||||
// 添付ファイル
|
// 添付ファイル
|
||||||
|
|
Loading…
Reference in New Issue