fix: name check bug (#434)

This commit is contained in:
Dream Hunter
2024-08-25 16:39:55 +08:00
committed by GitHub
parent a24cc1f642
commit a57a42b2a1
7 changed files with 14 additions and 9 deletions

View File

@@ -134,15 +134,16 @@ const checkNameBlockList = async (
c: Context<HonoCustomType>, name: string
): Promise<void> => {
// check name block list
const blockList = [] as string[];
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`);
}
blockList.push(...(value || []));
} catch (error) {
console.error(error);
}
if (blockList.some((item) => name.includes(item))) {
throw new Error(`Name[${name}]is blocked`);
}
}
export const cleanup = async (

View File

@@ -1,5 +1,5 @@
export const CONSTANTS = {
VERSION: 'v0.7.4',
VERSION: 'v0.7.5',
// DB settings
ADDRESS_BLOCK_LIST_KEY: 'address_block_list',