feat: add email blacklist filtering
This commit is contained in:
@@ -189,6 +189,15 @@
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting-item">
|
||||
<div><span>{{ $t('blackList') }}</span></div>
|
||||
<div>
|
||||
<el-button class="opt-button" style="margin-top: 0" @click="openBlackListForm" size="small"
|
||||
type="primary">
|
||||
<Icon icon="fluent:settings-48-regular" width="16" height="16"/>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -724,17 +733,31 @@
|
||||
</div>
|
||||
<div class="prefix-filter">
|
||||
<div style="margin-bottom: 10px;">{{ t('mustNotContain') }}</div>
|
||||
<el-input-tag style="margin-bottom: 10px;" v-model="emailPrefixFilter" :placeholder="t('mustNotContainDesc')" />
|
||||
<el-input-tag style="margin-bottom: 10px;" v-model="emailPrefixFilter" />
|
||||
</div>
|
||||
<el-button type="primary" style="width: 100%;" :loading="settingLoading" @click="saveEmailPrefix">{{ $t('save') }}</el-button>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="blackFormShow" :title="t('blackList')" class="forward-dialog" @closed="resetBlackList">
|
||||
<el-form>
|
||||
<el-form-item :label="t('blackFromDesc')" label-position="top">
|
||||
<el-input-tag v-model="blackListForm.blackFrom" @add-tag="banEmailAddTag" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('blackSubjectDesc')" label-position="top">
|
||||
<el-input-tag v-model="blackListForm.blackSubject"/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="t('blackContentDesc')" label-position="top">
|
||||
<el-input-tag v-model="blackListForm.blackContent"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-button type="primary" style="width: 100%;" :loading="settingLoading" @click="saveBlackList">{{ $t('save') }}</el-button>
|
||||
</el-dialog>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {computed, defineOptions, reactive, ref} from "vue";
|
||||
import {deleteBackground, setBackground, settingQuery, settingSet} from "@/request/setting.js";
|
||||
import {deleteBackground, setBackground, setBlackList, settingQuery, settingSet} from "@/request/setting.js";
|
||||
import {useSettingStore} from "@/store/setting.js";
|
||||
import {useUiStore} from "@/store/ui.js";
|
||||
import {useUserStore} from "@/store/user.js";
|
||||
@@ -743,7 +766,7 @@ import {Icon} from "@iconify/vue";
|
||||
import {cvtR2Url} from "@/utils/convert.js";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {debounce} from 'lodash-es'
|
||||
import {isEmail} from "@/utils/verify-utils.js";
|
||||
import {isDomain, isEmail} from "@/utils/verify-utils.js";
|
||||
import loading from "@/components/loading/index.vue";
|
||||
import {getTextWidth} from "@/utils/text.js";
|
||||
import {fileToBase64} from "@/utils/file-utils.js"
|
||||
@@ -765,6 +788,7 @@ const accountStore = useAccountStore();
|
||||
const userStore = useUserStore();
|
||||
const editTitleShow = ref(false)
|
||||
const resendTokenFormShow = ref(false)
|
||||
const blackFormShow = ref(false)
|
||||
const r2DomainShow = ref(false)
|
||||
const turnstileShow = ref(false)
|
||||
const tgSettingShow = ref(false)
|
||||
@@ -827,6 +851,12 @@ const regKeyOptions = computed(() => [
|
||||
{label: t('optional'), value: 2},
|
||||
])
|
||||
|
||||
const blackListForm = ref({
|
||||
blackSubject: [],
|
||||
blackContent: [],
|
||||
blackFrom: []
|
||||
})
|
||||
|
||||
const authRefreshOptions = computed(() => [
|
||||
{label: t('disable'), value: 0},
|
||||
{label: '3s', value: 3},
|
||||
@@ -874,6 +904,7 @@ function getSettings() {
|
||||
resetNoticeForm()
|
||||
resetAddS3Form()
|
||||
resetEmailPrefix()
|
||||
resetBlackList()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1148,6 +1179,11 @@ function resetEmailPrefix() {
|
||||
emailPrefixFilter.value = setting.value.emailPrefixFilter
|
||||
}
|
||||
|
||||
function resetBlackList() {
|
||||
blackListForm.value.blackFrom = setting.value.blackFrom ? setting.value.blackFrom.split(',') : []
|
||||
blackListForm.value.blackContent = setting.value.blackContent ? setting.value.blackContent.split(',') : []
|
||||
blackListForm.value.blackSubject = setting.value.blackSubject ? setting.value.blackSubject.split(',') : []
|
||||
}
|
||||
function saveEmailPrefix() {
|
||||
const form = {}
|
||||
form.minEmailPrefix = minEmailPrefix.value
|
||||
@@ -1160,6 +1196,44 @@ const opacityChange = debounce(doOpacityChange, 1000, {
|
||||
trailing: true
|
||||
})
|
||||
|
||||
function saveBlackList() {
|
||||
|
||||
let form = {
|
||||
blackContent: blackListForm.value.blackContent + '',
|
||||
blackSubject: blackListForm.value.blackSubject + '',
|
||||
blackFrom: blackListForm.value.blackFrom + ''
|
||||
}
|
||||
|
||||
settingLoading.value = true
|
||||
|
||||
setBlackList(form).then(() => {
|
||||
getSettings()
|
||||
ElMessage({
|
||||
message: t('setSuccess'),
|
||||
type: "success",
|
||||
plain: true
|
||||
})
|
||||
blackFormShow.value = false;
|
||||
}).finally(() => {
|
||||
settingLoading.value = false;
|
||||
})
|
||||
}
|
||||
|
||||
function banEmailAddTag(val) {
|
||||
const emails = Array.from(new Set(
|
||||
val.split(/[,,]/).map(item => item.trim()).filter(item => item)
|
||||
));
|
||||
|
||||
blackListForm.value.blackFrom.splice(blackListForm.value.blackFrom.length - 1, 1)
|
||||
|
||||
emails.forEach(email => {
|
||||
if ((isEmail(email) || isDomain(email)) && !blackListForm.value.blackFrom.includes(email)) {
|
||||
blackListForm.value.blackFrom.push(email)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function delBackground() {
|
||||
ElMessageBox.confirm(t('delBackgroundConfirm'), {
|
||||
confirmButtonText: t('confirm'),
|
||||
@@ -1245,6 +1319,10 @@ function openResendForm() {
|
||||
resendTokenFormShow.value = true
|
||||
}
|
||||
|
||||
function openBlackListForm() {
|
||||
blackFormShow.value = true
|
||||
}
|
||||
|
||||
function saveResendToken() {
|
||||
const settingForm = {
|
||||
resendTokens: {}
|
||||
|
||||
Reference in New Issue
Block a user