diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-11-09 14:15:52 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-11-09 14:15:52 +0900 |
| commit | 5b4205bdbc87f87c40fcf7c0d12e6451b18e0e20 (patch) | |
| tree | 6a3749e442dbde768b6ea934c5929efb23e322cc | |
| parent | [Client] Fix i18n (diff) | |
| parent | Rename: setDifference -> difference (#3177) (diff) | |
| download | sharkey-5b4205bdbc87f87c40fcf7c0d12e6451b18e0e20.tar.gz sharkey-5b4205bdbc87f87c40fcf7c0d12e6451b18e0e20.tar.bz2 sharkey-5b4205bdbc87f87c40fcf7c0d12e6451b18e0e20.zip | |
Merge branch 'develop' of https://github.com/syuilo/misskey into develop
| -rw-r--r-- | src/prelude/array.ts | 8 | ||||
| -rw-r--r-- | src/remote/activitypub/models/note.ts | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/prelude/array.ts b/src/prelude/array.ts index 8536e486d6..69b52fde87 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -18,8 +18,12 @@ export function erase<T>(x: T, xs: T[]): T[] { return xs.filter(y => x !== y); } -export function setDifference<T>(xs: T[], ys: T[]): T[] { - return xs.filter(x => !ys.includes(x)); +/** + * Finds the array of all elements in the first array not contained in the second array. + * The order of result values are determined by the first array. + */ +export function difference<T>(includes: T[], excludes: T[]): T[] { + return includes.filter(x => !excludes.includes(x)); } export function unique<T>(xs: T[]): T[] { diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index ce9a4daf16..7501bf1a89 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -13,7 +13,7 @@ import htmlToMFM from '../../../mfm/html-to-mfm'; import Emoji from '../../../models/emoji'; import { ITag } from './tag'; import { toUnicode } from 'punycode'; -import { unique, concat, setDifference } from '../../../prelude/array'; +import { unique, concat, difference } from '../../../prelude/array'; const log = debug('misskey:activitypub'); @@ -181,7 +181,7 @@ async function extractEmojis(tags: ITag[], host_: string) { async function extractMentionedUsers(actor: IRemoteUser, to: string[], cc: string[], resolver: Resolver) { const ignoreUris = ['https://www.w3.org/ns/activitystreams#Public', `${actor.uri}/followers`]; - const uris = setDifference(unique(concat([to || [], cc || []])), ignoreUris); + const uris = difference(unique(concat([to || [], cc || []])), ignoreUris); const users = await Promise.all( uris.map(async uri => await resolvePerson(uri, null, resolver).catch(() => null)) |