From 3b7bcea826e4ac15d77c122e4513d4c91d32d2a2 Mon Sep 17 00:00:00 2001 From: Ilja Date: Fri, 23 Jul 2021 03:41:03 +0000 Subject: [PATCH] Make MRF and Quarantine work with tuples * I added the keys to normaliser.js --- src/store/modules/normalizers.js | 15 +++++++++++++-- .../inputComponents/EditableKeywordInput.vue | 14 ++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/store/modules/normalizers.js b/src/store/modules/normalizers.js index 150865d0..d286f379 100644 --- a/src/store/modules/normalizers.js +++ b/src/store/modules/normalizers.js @@ -78,14 +78,25 @@ export const parseTuples = (tuples, key) => { item.tuple[0] === ':replace' || item.tuple[0] === ':retries' || (item.tuple[0] === ':headers' && key === 'Pleroma.Web.MediaProxy.Invalidation.Http') || - item.tuple[0] === ':crontab')) { + item.tuple[0] === ':crontab' || + item.tuple[0] === ':transparency_exclusions' || + item.tuple[0] === ':quarantined_instances' || + key === ':mrf_simple')) { if (item.tuple[0] === ':crontab') { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { return [...acc, { [group.tuple[1]]: { value: group.tuple[0], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] }, []) } else { accum[item.tuple[0]] = item.tuple[1].reduce((acc, group) => { - return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] + /** + * The ':quarantined_instances' and ':mrf_simple' settings have changed to a list of tuples instead of a list of strings. + * This is to have backwards compatibility for instances that still use strings. + */ + if (typeof group === 'string') { + return [...acc, group] + } else { + return [...acc, { [group.tuple[0]]: { value: group.tuple[1], id: `f${(~~(Math.random() * 1e8)).toString(16)}` }}] + } }, []) } } else if (item.tuple[0] === ':icons') { diff --git a/src/views/settings/components/inputComponents/EditableKeywordInput.vue b/src/views/settings/components/inputComponents/EditableKeywordInput.vue index 727ff0da..e4c4f003 100644 --- a/src/views/settings/components/inputComponents/EditableKeywordInput.vue +++ b/src/views/settings/components/inputComponents/EditableKeywordInput.vue @@ -87,7 +87,12 @@ export default { return this.$store.state.app.device === 'desktop' }, keyPlaceholder() { - return this.setting.key === ':replace' ? 'pattern' : 'key' + /** + * We can get 'key_placeholder' from the Pleroma BE. This wasn't always the case. + * We check for the key ':replace' for backwards compatibility for older Pleroma instances who didn't send 'key_placeholder' yet. + * The ':replace' key was the only key where this was needed. + */ + return this.setting.key_placeholder ? this.setting.key_placeholder : (this.setting.key === ':replace' ? 'pattern' : 'key') }, settings() { return this.$store.state.settings.settings @@ -96,7 +101,12 @@ export default { return this.$store.state.settings.updatedSettings }, valuePlaceholder() { - return this.setting.key === ':replace' ? 'replacement' : 'value' + /** + * We can get 'value_placeholder' from the Pleroma BE. This wasn't always the case. + * We check for the key ':replace' for backwards compatibility for older Pleroma instances who didn't send 'value_placeholder' yet. + * The ':replace' key was the only key where this was needed. + */ + return this.setting.value_placeholder ? this.setting.value_placeholder : (this.setting.key === ':replace' ? 'replacement' : 'value') } }, methods: {