diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-10-15 22:55:27 +0200 |
---|---|---|
committer | ThibG <thib@sitedethib.com> | 2019-10-17 11:43:58 +0200 |
commit | 003bb6ca1a3f57ffb51092161d8f851b8dc93ab6 (patch) | |
tree | 94f2a00cad7a921d885cbf3ed17f858df0791c28 /app/javascript/flavours/glitch/actions/importer/normalizer.js | |
parent | b4046dc0268cbc81c67ed3f54833b78103697137 (diff) |
Refactor timeline filtering code
Diffstat (limited to 'app/javascript/flavours/glitch/actions/importer/normalizer.js')
-rw-r--r-- | app/javascript/flavours/glitch/actions/importer/normalizer.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/actions/importer/normalizer.js b/app/javascript/flavours/glitch/actions/importer/normalizer.js index b35c4d7bd..2bc603930 100644 --- a/app/javascript/flavours/glitch/actions/importer/normalizer.js +++ b/app/javascript/flavours/glitch/actions/importer/normalizer.js @@ -10,6 +10,12 @@ const makeEmojiMap = record => record.emojis.reduce((obj, emoji) => { return obj; }, {}); +export function searchTextFromRawStatus (status) { + const spoilerText = status.spoiler_text || ''; + const searchContent = ([spoilerText, status.content].concat((status.poll && status.poll.options) ? status.poll.options.map(option => option.title) : [])).join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n'); + return domParser.parseFromString(searchContent, 'text/html').documentElement.textContent; +} + export function normalizeAccount(account) { account = { ...account }; |