mirror of
https://github.com/funamitech/mastodon
synced 2024-12-13 14:18:34 +09:00
70d346ea95
Fixes #778
25 lines
502 B
JavaScript
25 lines
502 B
JavaScript
export function autoUnfoldCW (settings, status) {
|
|
if (!settings.getIn(['content_warnings', 'auto_unfold'])) {
|
|
return false;
|
|
}
|
|
|
|
const rawRegex = settings.getIn(['content_warnings', 'filter']);
|
|
|
|
if (!rawRegex) {
|
|
return true;
|
|
}
|
|
|
|
let regex = null;
|
|
|
|
try {
|
|
regex = rawRegex && new RegExp(rawRegex.trim(), 'i');
|
|
} catch (e) {
|
|
// Bad regex, don't affect filters
|
|
}
|
|
|
|
if (!(status && regex)) {
|
|
return undefined;
|
|
}
|
|
return !regex.test(status.get('spoiler_text'));
|
|
}
|