parent
21d9afebc3
commit
a9436306ab
@ -18,6 +18,10 @@ export function erase<T>(x: T, xs: T[]): T[] {
|
|||||||
return xs.filter(y => x !== y);
|
return xs.filter(y => x !== y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setDifference<T>(xs: T[], ys: T[]): T[] {
|
||||||
|
return xs.filter(x => !ys.includes(x));
|
||||||
|
}
|
||||||
|
|
||||||
export function unique<T>(xs: T[]): T[] {
|
export function unique<T>(xs: T[]): T[] {
|
||||||
return [...new Set(xs)];
|
return [...new Set(xs)];
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import htmlToMFM from '../../../mfm/html-to-mfm';
|
|||||||
import Emoji from '../../../models/emoji';
|
import Emoji from '../../../models/emoji';
|
||||||
import { ITag } from './tag';
|
import { ITag } from './tag';
|
||||||
import { toUnicode } from 'punycode';
|
import { toUnicode } from 'punycode';
|
||||||
import { unique } from '../../../prelude/array';
|
import { unique, concat, setDifference } from '../../../prelude/array';
|
||||||
|
|
||||||
const log = debug('misskey:activitypub');
|
const log = debug('misskey:activitypub');
|
||||||
|
|
||||||
@ -179,15 +179,9 @@ async function extractEmojis(tags: ITag[], host_: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function extractMentionedUsers(actor: IRemoteUser, to: string[], cc: string[], resolver: Resolver ) {
|
async function extractMentionedUsers(actor: IRemoteUser, to: string[], cc: string[], resolver: Resolver) {
|
||||||
let uris = [] as string[];
|
const ignoreUris = ['https://www.w3.org/ns/activitystreams#Public', `${actor.uri}/followers`];
|
||||||
|
const uris = setDifference(unique(concat([to || [], cc || []])), ignoreUris);
|
||||||
if (to) uris.concat(to);
|
|
||||||
if (cc) uris.concat(cc);
|
|
||||||
|
|
||||||
uris = uris.filter(x => x !== 'https://www.w3.org/ns/activitystreams#Public');
|
|
||||||
uris = uris.filter(x => x !== `${actor.uri}/followers`);
|
|
||||||
uris = unique(uris);
|
|
||||||
|
|
||||||
const users = await Promise.all(
|
const users = await Promise.all(
|
||||||
uris.map(async uri => await resolvePerson(uri, null, resolver).catch(() => null))
|
uris.map(async uri => await resolvePerson(uri, null, resolver).catch(() => null))
|
||||||
|
Loading…
Reference in New Issue
Block a user