mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-08-28 19:48:01 +08:00
feat: add sendBlockList (#198)
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
# CHANGE LOG
|
# CHANGE LOG
|
||||||
|
|
||||||
|
## main branch
|
||||||
|
|
||||||
|
- 修复 Admin 删除邮件报错
|
||||||
|
- UI: 回复邮件按钮, 引用原始邮件文本
|
||||||
|
- 添加发送邮件地址黑名单
|
||||||
|
|
||||||
## v0.3.2
|
## v0.3.2
|
||||||
|
|
||||||
## What's Changed
|
## What's Changed
|
||||||
|
|||||||
@@ -16,22 +16,26 @@ const { t } = useI18n({
|
|||||||
successTip: 'Save Success',
|
successTip: 'Save Success',
|
||||||
address_block_list: 'Address Block Keywords for Users(Admin can skip)',
|
address_block_list: 'Address Block Keywords for Users(Admin can skip)',
|
||||||
address_block_list_placeholder: 'Please enter the keywords you want to block',
|
address_block_list_placeholder: 'Please enter the keywords you want to block',
|
||||||
|
send_address_block_list: 'Address Block Keywords for send email',
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
save: '保存',
|
save: '保存',
|
||||||
successTip: '保存成功',
|
successTip: '保存成功',
|
||||||
address_block_list: '用户地址屏蔽关键词(管理员可跳过检查)',
|
address_block_list: '用户地址屏蔽关键词(管理员可跳过检查)',
|
||||||
address_block_list_placeholder: '请输入您想要屏蔽的关键词',
|
address_block_list_placeholder: '请输入您想要屏蔽的关键词',
|
||||||
|
send_address_block_list: '发送邮件地址屏蔽关键词',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const addressBlockList = ref([])
|
const addressBlockList = ref([])
|
||||||
|
const sendAddressBlockList = ref([])
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await api.fetch(`/admin/account_settings`)
|
const res = await api.fetch(`/admin/account_settings`)
|
||||||
addressBlockList.value = res.blockList || []
|
addressBlockList.value = res.blockList || []
|
||||||
|
sendAddressBlockList.value = res.sendBlockList || []
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error.message || "error");
|
message.error(error.message || "error");
|
||||||
}
|
}
|
||||||
@@ -42,7 +46,8 @@ const save = async () => {
|
|||||||
await api.fetch(`/admin/account_settings`, {
|
await api.fetch(`/admin/account_settings`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
blockList: addressBlockList.value || []
|
blockList: addressBlockList.value || [],
|
||||||
|
sendBlockList: sendAddressBlockList.value || []
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
message.success(t('successTip'))
|
message.success(t('successTip'))
|
||||||
@@ -64,6 +69,10 @@ onMounted(async () => {
|
|||||||
<n-select v-model:value="addressBlockList" filterable multiple tag
|
<n-select v-model:value="addressBlockList" filterable multiple tag
|
||||||
:placeholder="t('address_block_list_placeholder')" />
|
:placeholder="t('address_block_list_placeholder')" />
|
||||||
</n-form-item-row>
|
</n-form-item-row>
|
||||||
|
<n-form-item-row :label="t('send_address_block_list')">
|
||||||
|
<n-select v-model:value="sendAddressBlockList" filterable multiple tag
|
||||||
|
:placeholder="t('address_block_list_placeholder')" />
|
||||||
|
</n-form-item-row>
|
||||||
<n-button @click="save" type="primary" block :loading="loading">
|
<n-button @click="save" type="primary" block :loading="loading">
|
||||||
{{ t('save') }}
|
{{ t('save') }}
|
||||||
</n-button>
|
</n-button>
|
||||||
|
|||||||
+11
-5
@@ -303,9 +303,11 @@ api.post('/admin/auto_cleanup', cleanup_api.saveCleanup)
|
|||||||
|
|
||||||
api.get('/admin/account_settings', async (c) => {
|
api.get('/admin/account_settings', async (c) => {
|
||||||
try {
|
try {
|
||||||
const value = await getJsonSetting(c, CONSTANTS.ADDRESS_BLOCK_LIST_KEY);
|
const blockList = await getJsonSetting(c, CONSTANTS.ADDRESS_BLOCK_LIST_KEY);
|
||||||
|
const sendBlockList = await getJsonSetting(c, CONSTANTS.SEND_BLOCK_LIST_KEY);
|
||||||
return c.json({
|
return c.json({
|
||||||
blockList: value || []
|
blockList: blockList || [],
|
||||||
|
sendBlockList: sendBlockList || []
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
@@ -314,14 +316,18 @@ api.get('/admin/account_settings', async (c) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
api.post('/admin/account_settings', async (c) => {
|
api.post('/admin/account_settings', async (c) => {
|
||||||
const { blockList } = await c.req.json();
|
const { blockList, sendBlockList } = await c.req.json();
|
||||||
if (!blockList) {
|
if (!blockList || !sendBlockList) {
|
||||||
return c.text("Invalid blockList", 400)
|
return c.text("Invalid blockList or sendBlockList", 400)
|
||||||
}
|
}
|
||||||
await saveSetting(
|
await saveSetting(
|
||||||
c, CONSTANTS.ADDRESS_BLOCK_LIST_KEY,
|
c, CONSTANTS.ADDRESS_BLOCK_LIST_KEY,
|
||||||
JSON.stringify(blockList)
|
JSON.stringify(blockList)
|
||||||
);
|
);
|
||||||
|
await saveSetting(
|
||||||
|
c, CONSTANTS.SEND_BLOCK_LIST_KEY,
|
||||||
|
JSON.stringify(sendBlockList)
|
||||||
|
);
|
||||||
return c.json({
|
return c.json({
|
||||||
success: true
|
success: true
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
export const CONSTANTS = {
|
export const CONSTANTS = {
|
||||||
ADDRESS_BLOCK_LIST_KEY: 'address_block_list',
|
ADDRESS_BLOCK_LIST_KEY: 'address_block_list',
|
||||||
|
SEND_BLOCK_LIST_KEY: 'send_block_list',
|
||||||
AUTO_CLEANUP_KEY: 'auto_cleanup',
|
AUTO_CLEANUP_KEY: 'auto_cleanup',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { Hono } from 'hono'
|
import { Hono } from 'hono'
|
||||||
|
import { CONSTANTS } from './constants'
|
||||||
|
import { getJsonSetting } from './utils';
|
||||||
|
|
||||||
const api = new Hono()
|
const api = new Hono()
|
||||||
|
|
||||||
@@ -47,6 +49,11 @@ api.post('/api/send_mail', async (c) => {
|
|||||||
if (!to_mail) {
|
if (!to_mail) {
|
||||||
return c.text("Invalid to mail", 400)
|
return c.text("Invalid to mail", 400)
|
||||||
}
|
}
|
||||||
|
// check SEND_BLOCK_LIST_KEY
|
||||||
|
const sendBlockList = await getJsonSetting(c, CONSTANTS.SEND_BLOCK_LIST_KEY);
|
||||||
|
if (sendBlockList && sendBlockList.some((item) => to_mail.includes(item))) {
|
||||||
|
return c.text("to_mail address is blocked", 400);
|
||||||
|
}
|
||||||
from_name = from_name || address;
|
from_name = from_name || address;
|
||||||
to_name = to_name || to_mail;
|
to_name = to_name || to_mail;
|
||||||
if (!subject) {
|
if (!subject) {
|
||||||
|
|||||||
Reference in New Issue
Block a user