This commit is contained in:
syuilo 2018-10-30 21:55:16 +09:00
parent 4c160869b8
commit 120474ec6a
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 26 additions and 6 deletions

View file

@ -611,19 +611,21 @@ function incNotesCount(user: IUser) {
async function extractMentionedUsers(tokens: ReturnType<typeof parse>): Promise<IUser[]> {
if (tokens == null) return [];
const mentionTokens = unique(
tokens
.filter(t => t.type == 'mention') as TextElementMention[]
);
const mentionTokens = tokens
.filter(t => t.type == 'mention') as TextElementMention[];
const mentionedUsers = unique(
let mentionedUsers =
erase(null, await Promise.all(mentionTokens.map(async m => {
try {
return await resolveUser(m.username, m.host);
} catch (e) {
return null;
}
})))
})));
// Drop duplicate users
mentionedUsers = mentionedUsers.filter((u, i, self) =>
i === self.findIndex(u2 => u._id.equals(u2._id))
);
return mentionedUsers;