From edf2503ee51cdca923805d68813f99e7b1ea1f75 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 21 Jul 2018 11:06:01 +0900 Subject: [PATCH] :100: --- src/services/note/create.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 2d4699f8a..03ca90829 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -495,18 +495,20 @@ function incNotesCount(user: IUser) { async function extractMentionedUsers(tokens: ReturnType): Promise { if (tokens == null) return []; - // TODO: Drop dupulicates - const mentionTokens = tokens - .filter(t => t.type == 'mention') as TextElementMention[]; + const mentionTokens = [...new Set( + tokens + .filter(t => t.type == 'mention') as TextElementMention[] + )]; - // TODO: Drop dupulicates - const mentionedUsers = (await Promise.all(mentionTokens.map(async m => { - try { - return await resolveUser(m.username, m.host); - } catch (e) { - return null; - } - }))).filter(x => x != null); + const mentionedUsers = [...new Set( + (await Promise.all(mentionTokens.map(async m => { + try { + return await resolveUser(m.username, m.host); + } catch (e) { + return null; + } + }))).filter(x => x != null) + )]; return mentionedUsers; }