mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Use raw mode on custom or broken sieve file (#3387)
* Use raw mode on custom or broken sieve file * Fixed display of sieve filters when none are active * Updated test
This commit is contained in:
@@ -36,8 +36,10 @@ _axios.interceptors.response.use(
|
||||
return Promise.reject(error)
|
||||
}
|
||||
if (error.response.status !== 401 || router.currentRoute.name === 'Login') {
|
||||
const busStore = useBusStore()
|
||||
busStore.displayNotification({ msg: error.response.data, type: 'error' })
|
||||
if (error.response.status !== 518) {
|
||||
const busStore = useBusStore()
|
||||
busStore.displayNotification({ msg: error.response.data, type: 'error' })
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
const refreshToken = Cookies.get('refreshToken')
|
||||
|
||||
@@ -200,6 +200,9 @@ function getFilterSetName(filterSet) {
|
||||
if (filterSet.active) {
|
||||
result += ' (' + $gettext('active') + ')'
|
||||
}
|
||||
else {
|
||||
result += ' (' + $gettext('inactive') + ')'
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -216,7 +219,12 @@ function closeFilterForm() {
|
||||
|
||||
function fetchFilterSets() {
|
||||
accountApi.getFilterSets().then(resp => {
|
||||
filterSets.value = resp.data
|
||||
if (resp.data.length > 0 && resp.data[0].active && resp.data[0].name === null) {
|
||||
// No filter is active
|
||||
filterSets.value = resp.data.slice(1)
|
||||
} else {
|
||||
filterSets.value = resp.data
|
||||
}
|
||||
if (!currentFilterSet.value && route.params.filterset) {
|
||||
for (const filterSet of filterSets.value) {
|
||||
if (filterSet.name === route.params.filterset) {
|
||||
@@ -233,6 +241,12 @@ function fetchFilters(filterSetName) {
|
||||
accountApi.getFilters(filterSetName).then(resp => {
|
||||
filters.value = resp.data
|
||||
loadingFilters.value = false
|
||||
}).catch(error => {
|
||||
if (error.response.status === 518) { // Server is a teapot (sieve file contains custom code or is broken)
|
||||
// Let the user see with rawmode
|
||||
rawMode.value = true
|
||||
busStore.displayNotification({ msg: $gettext('Failed to display template. Using raw mode'), type: 'warning' })
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user