diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2018-11-09 08:44:19 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2018-11-09 08:44:19 +0900 |
| commit | 5b684c6deb50e0f642b71bf354cacaf871b514e4 (patch) | |
| tree | 880a9466c84975c667d077f6aee92d6478490ead /src/remote/activitypub | |
| parent | [Client] Fix #3168 (diff) | |
| download | misskey-5b684c6deb50e0f642b71bf354cacaf871b514e4.tar.gz misskey-5b684c6deb50e0f642b71bf354cacaf871b514e4.tar.bz2 misskey-5b684c6deb50e0f642b71bf354cacaf871b514e4.zip | |
On remote notes, not use content for detecting mentions (#3170)
* On remote note, detect mentioned users from to/cc
* fix
Diffstat (limited to 'src/remote/activitypub')
| -rw-r--r-- | src/remote/activitypub/models/note.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/remote/activitypub/models/note.ts b/src/remote/activitypub/models/note.ts index be6c1bcd18..f9380eb4f4 100644 --- a/src/remote/activitypub/models/note.ts +++ b/src/remote/activitypub/models/note.ts @@ -13,6 +13,7 @@ import htmlToMFM from '../../../mfm/html-to-mfm'; import Emoji from '../../../models/emoji'; import { ITag } from './tag'; import { toUnicode } from 'punycode'; +import { unique } from '../../../prelude/array'; const log = debug('misskey:activitypub'); @@ -81,6 +82,8 @@ export async function createNote(value: any, resolver?: Resolver, silent = false } //#endergion + const apMentions = await extractMentionedUsers(actor, note.to, note.cc, resolver); + // 添付ファイル // TODO: attachmentは必ずしもImageではない // TODO: attachmentは必ずしも配列ではない @@ -116,6 +119,7 @@ export async function createNote(value: any, resolver?: Resolver, silent = false geo: undefined, visibility, visibleUsers, + apMentions, uri: note.id }, silent); } @@ -174,3 +178,20 @@ async function extractEmojis(tags: ITag[], host_: string) { }) ); } + +async function extractMentionedUsers(actor: IRemoteUser, to: string[], cc: string[], resolver: Resolver ) { + let uris = [] as string[]; + + 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( + uris.map(async uri => await resolvePerson(uri, null, resolver).catch(() => null)) + ); + + return users.filter(x => x != null); +} |