|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
import escapeTextContentForBrowser from 'escape-html'; |
|
|
|
|
import { createSelector } from 'reselect'; |
|
|
|
|
import { List as ImmutableList, is } from 'immutable'; |
|
|
|
|
import { me } from 'flavours/glitch/util/initial_state'; |
|
|
|
@ -90,10 +91,12 @@ export const makeGetStatus = () => { |
|
|
|
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', id, 'account'])]), |
|
|
|
|
(state, { id }) => state.getIn(['accounts', state.getIn(['statuses', state.getIn(['statuses', id, 'reblog']), 'account'])]), |
|
|
|
|
(state, _) => state.getIn(['local_settings', 'filtering_behavior']), |
|
|
|
|
(state, _) => state.get('filters', ImmutableList()), |
|
|
|
|
(_, { contextType }) => contextType, |
|
|
|
|
getFiltersRegex, |
|
|
|
|
], |
|
|
|
|
|
|
|
|
|
(statusBase, statusReblog, accountBase, accountReblog, filteringBehavior, filtersRegex) => { |
|
|
|
|
(statusBase, statusReblog, accountBase, accountReblog, filteringBehavior, filters, contextType, filtersRegex) => { |
|
|
|
|
if (!statusBase) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
@ -119,6 +122,22 @@ export const makeGetStatus = () => { |
|
|
|
|
|
|
|
|
|
if (filtered && filteringBehavior === 'drop') { |
|
|
|
|
return null; |
|
|
|
|
} else if (filtered && filteringBehavior === 'content_warning') { |
|
|
|
|
let spoilerText = (statusReblog || statusBase).get('spoiler_text', ''); |
|
|
|
|
const searchIndex = (statusReblog || statusBase).get('search_index'); |
|
|
|
|
const serverSideType = toServerSideType(contextType); |
|
|
|
|
const enabledFilters = filters.filter(filter => filter.get('context').includes(serverSideType) && (filter.get('expires_at') === null || Date.parse(filter.get('expires_at')) > (new Date()))).toArray(); |
|
|
|
|
const matchingFilters = enabledFilters.filter(filter => { |
|
|
|
|
const regexp = regexFromFilters([filter]); |
|
|
|
|
return regexp.test(searchIndex) && !regexp.test(spoilerText); |
|
|
|
|
}); |
|
|
|
|
if (statusReblog) { |
|
|
|
|
statusReblog = statusReblog.set('spoiler_text', matchingFilters.map(filter => filter.get('phrase')).concat([spoilerText]).filter(cw => !!cw).join(', ')); |
|
|
|
|
statusReblog = statusReblog.update('spoilerHtml', '', spoilerText => matchingFilters.map(filter => escapeTextContentForBrowser(filter.get('phrase'))).concat([spoilerText]).filter(cw => !!cw).join(', ')); |
|
|
|
|
} else { |
|
|
|
|
statusBase = statusBase.set('spoiler_text', matchingFilters.map(filter => filter.get('phrase')).concat([spoilerText]).filter(cw => !!cw).join(', ')); |
|
|
|
|
statusBase = statusBase.update('spoilerHtml', '', spoilerText => matchingFilters.map(filter => escapeTextContentForBrowser(filter.get('phrase'))).concat([spoilerText]).filter(cw => !!cw).join(', ')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return statusBase.withMutations(map => { |
|
|
|
|