Make MRF and Quarantine work with tuples

* I added the keys to normaliser.js
This commit is contained in:
Ilja 2021-07-23 03:41:03 +00:00 committed by Haelwenn
parent 0e36395a3e
commit 3b7bcea826
2 changed files with 25 additions and 4 deletions

View File

@ -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') {

View File

@ -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: {