about summary refs log tree commit diff
path: root/app/javascript/mastodon/actions/importer/normalizer.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-05-06 11:48:51 +0200
committerGitHub <noreply@github.com>2018-05-06 11:48:51 +0200
commit61a90186070395e133ad2f8e959bdf003a8615ca (patch)
tree49596898f7e5c72116db1d181847f5925a033c59 /app/javascript/mastodon/actions/importer/normalizer.js
parentbd10a7e48076c913a652c347b0477496be8813fa (diff)
Enable custom emojis in profiles (notes, field values, display names) (#7374)
Follow-up to #6124
Diffstat (limited to 'app/javascript/mastodon/actions/importer/normalizer.js')
-rw-r--r--app/javascript/mastodon/actions/importer/normalizer.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js
index 5f1274fab..057bff58b 100644
--- a/app/javascript/mastodon/actions/importer/normalizer.js
+++ b/app/javascript/mastodon/actions/importer/normalizer.js
@@ -3,18 +3,25 @@ import emojify from '../../features/emoji/emoji';
 
 const domParser = new DOMParser();
 
+const makeEmojiMap = record => record.emojis.reduce((obj, emoji) => {
+  obj[`:${emoji.shortcode}:`] = emoji;
+  return obj;
+}, {});
+
 export function normalizeAccount(account) {
   account = { ...account };
 
+  const emojiMap = makeEmojiMap(account);
   const displayName = account.display_name.length === 0 ? account.username : account.display_name;
-  account.display_name_html = emojify(escapeTextContentForBrowser(displayName));
-  account.note_emojified = emojify(account.note);
+
+  account.display_name_html = emojify(escapeTextContentForBrowser(displayName), emojiMap);
+  account.note_emojified = emojify(account.note, emojiMap);
 
   if (account.fields) {
     account.fields = account.fields.map(pair => ({
       ...pair,
       name_emojified: emojify(escapeTextContentForBrowser(pair.name)),
-      value_emojified: emojify(pair.value),
+      value_emojified: emojify(pair.value, emojiMap),
     }));
   }
 
@@ -42,11 +49,7 @@ export function normalizeStatus(status, normalOldStatus) {
     normalStatus.hidden = normalOldStatus.get('hidden');
   } else {
     const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
-
-    const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
-      obj[`:${emoji.shortcode}:`] = emoji;
-      return obj;
-    }, {});
+    const emojiMap = makeEmojiMap(normalStatus);
 
     normalStatus.search_index = domParser.parseFromString(searchContent, 'text/html').documentElement.textContent;
     normalStatus.contentHtml  = emojify(normalStatus.content, emojiMap);