From fa124abbe26abca49bd33f4eec49e691c5d029f9 Mon Sep 17 00:00:00 2001
From: MeiMei <30769358+mei23@users.noreply.github.com>
Date: Wed, 23 Jan 2019 04:49:16 +0900
Subject: [PATCH] Supports Twemoji / CustomEmoji in poll (#3960)
* Supports Twemoji / CustomEmoji in poll
* extract emojis in polls
---
src/client/app/common/views/components/poll.vue | 2 +-
src/services/note/create.ts | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/client/app/common/views/components/poll.vue b/src/client/app/common/views/components/poll.vue
index 8817d88cc..6a9bc786d 100644
--- a/src/client/app/common/views/components/poll.vue
+++ b/src/client/app/common/views/components/poll.vue
@@ -5,7 +5,7 @@
- {{ choice.text }}
+
({{ $t('vote-count').replace('{}', choice.votes) }})
diff --git a/src/services/note/create.ts b/src/services/note/create.ts
index 4b9f8215e..d3c8699b2 100644
--- a/src/services/note/create.ts
+++ b/src/services/note/create.ts
@@ -1,5 +1,5 @@
import es from '../../db/elasticsearch';
-import Note, { pack, INote } from '../../models/note';
+import Note, { pack, INote, IChoice } from '../../models/note';
import User, { isLocalUser, IUser, isRemoteUser, IRemoteUser, ILocalUser } from '../../models/user';
import { publishMainStream, publishHomeTimelineStream, publishLocalTimelineStream, publishHybridTimelineStream, publishGlobalTimelineStream, publishUserListStream, publishHashtagStream } from '../../stream';
import Following from '../../models/following';
@@ -25,7 +25,7 @@ import notesChart from '../../chart/notes';
import perUserNotesChart from '../../chart/per-user-notes';
import activeUsersChart from '../../chart/active-users';
-import { erase } from '../../prelude/array';
+import { erase, concat } from '../../prelude/array';
import insertNoteUnread from './unread';
import registerInstance from '../register-instance';
import Instance from '../../models/instance';
@@ -157,7 +157,11 @@ export default async (user: IUser, data: Option, silent = false) => new Promise<
if (!tags || !emojis || !mentionedUsers) {
const tokens = data.text ? parse(data.text) : [];
const cwTokens = data.cw ? parse(data.cw) : [];
- const combinedTokens = tokens.concat(cwTokens);
+ const choiceTokens = data.poll && data.poll.choices
+ ? concat((data.poll.choices as IChoice[]).map(choice => parse(choice.text)))
+ : [];
+
+ const combinedTokens = tokens.concat(cwTokens).concat(choiceTokens);
tags = data.apHashtags || extractHashtags(combinedTokens);