mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-06 16:07:14 +08:00
fix: bugs && release v0.7.4 (#432)
This commit is contained in:
+3
-1
@@ -1,9 +1,11 @@
|
|||||||
<!-- markdownlint-disable-file MD004 MD024 MD034 MD036 -->
|
<!-- markdownlint-disable-file MD004 MD024 MD034 MD036 -->
|
||||||
# CHANGE LOG
|
# CHANGE LOG
|
||||||
|
|
||||||
## main(v0.7.4)
|
## v0.7.4
|
||||||
|
|
||||||
- feat: UI 列表页面增加最小宽度
|
- feat: UI 列表页面增加最小宽度
|
||||||
|
- fix: 修复 `name` 的校验检查
|
||||||
|
- fix: 修复 `DEFAULT_DOMAINS` 配置为空不生效的问题
|
||||||
|
|
||||||
## v0.7.3
|
## v0.7.3
|
||||||
|
|
||||||
|
|||||||
+21
-3
@@ -1,7 +1,7 @@
|
|||||||
import { Context } from 'hono';
|
import { Context } from 'hono';
|
||||||
import { Jwt } from 'hono/utils/jwt'
|
import { Jwt } from 'hono/utils/jwt'
|
||||||
|
|
||||||
import { getBooleanValue, getDomains, getStringValue, getIntValue, getUserRoles, getDefaultDomains } from './utils';
|
import { getBooleanValue, getDomains, getStringValue, getIntValue, getUserRoles, getDefaultDomains, getJsonSetting } from './utils';
|
||||||
import { HonoCustomType, UserRole } from './types';
|
import { HonoCustomType, UserRole } from './types';
|
||||||
import { unbindTelegramByAddress } from './telegram_api/common';
|
import { unbindTelegramByAddress } from './telegram_api/common';
|
||||||
import { CONSTANTS } from './constants';
|
import { CONSTANTS } from './constants';
|
||||||
@@ -60,10 +60,13 @@ export const newAddress = async (
|
|||||||
enableCheckNameRegex?: boolean,
|
enableCheckNameRegex?: boolean,
|
||||||
}
|
}
|
||||||
): Promise<{ address: string, jwt: string }> => {
|
): Promise<{ address: string, jwt: string }> => {
|
||||||
// check name
|
|
||||||
if (enableCheckNameRegex) checkNameRegex(c, name);
|
|
||||||
// remove special characters
|
// remove special characters
|
||||||
name = name.replace(getNameRegex(c), '')
|
name = name.replace(getNameRegex(c), '')
|
||||||
|
// check name
|
||||||
|
if (enableCheckNameRegex) {
|
||||||
|
await checkNameBlockList(c, name);
|
||||||
|
checkNameRegex(c, name);
|
||||||
|
}
|
||||||
// name min length min 1
|
// name min length min 1
|
||||||
const minAddressLength = Math.max(
|
const minAddressLength = Math.max(
|
||||||
checkLengthByConfig ? getIntValue(c.env.MIN_ADDRESS_LEN, 1) : 1,
|
checkLengthByConfig ? getIntValue(c.env.MIN_ADDRESS_LEN, 1) : 1,
|
||||||
@@ -127,6 +130,21 @@ export const newAddress = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkNameBlockList = async (
|
||||||
|
c: Context<HonoCustomType>, name: string
|
||||||
|
): Promise<void> => {
|
||||||
|
// check name block list
|
||||||
|
try {
|
||||||
|
const value = await getJsonSetting(c, CONSTANTS.ADDRESS_BLOCK_LIST_KEY);
|
||||||
|
const blockList = (value || []) as string[];
|
||||||
|
if (blockList.some((item) => name.includes(item))) {
|
||||||
|
throw new Error(`Name[${name}]is blocked`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const cleanup = async (
|
export const cleanup = async (
|
||||||
c: Context<HonoCustomType>,
|
c: Context<HonoCustomType>,
|
||||||
cleanType: string | undefined | null,
|
cleanType: string | undefined | null,
|
||||||
|
|||||||
+4
-2
@@ -97,9 +97,11 @@ export const getStringArray = (
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getDefaultDomains = (c: Context<HonoCustomType>): string[] => {
|
export const getDefaultDomains = (c: Context<HonoCustomType>): string[] => {
|
||||||
|
if (c.env.DEFAULT_DOMAINS == undefined || c.env.DEFAULT_DOMAINS == null) {
|
||||||
|
return getDomains(c);
|
||||||
|
}
|
||||||
const domains = getStringArray(c.env.DEFAULT_DOMAINS);
|
const domains = getStringArray(c.env.DEFAULT_DOMAINS);
|
||||||
if (domains && domains.length > 0) return domains;
|
return domains || getDomains(c);
|
||||||
return getDomains(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getDomains = (c: Context<HonoCustomType>): string[] => {
|
export const getDomains = (c: Context<HonoCustomType>): string[] => {
|
||||||
|
|||||||
Reference in New Issue
Block a user