feat: add global forward address list (#288)

This commit is contained in:
Dream Hunter
2024-05-31 23:21:12 +08:00
committed by GitHub
parent f882e4cf97
commit 7a368d7b23
7 changed files with 36 additions and 0 deletions

View File

@@ -129,6 +129,23 @@ export const getAdminPasswords = (c: Context<HonoCustomType>): string[] => {
return c.env.ADMIN_PASSWORDS.filter((item) => item.length > 0);
}
export const getEnvStringList = (value: string | string[] | undefined): string[] => {
if (!value) {
return [];
}
// check if is an array, if not use json.parse
if (!Array.isArray(value)) {
try {
const res = JSON.parse(value) as string[];
return res.filter((item) => item.length > 0);
} catch (e) {
console.error("Failed to parse ADMIN_PASSWORDS", e);
return [];
}
}
return value.filter((item) => item.length > 0);
}
export const sendAdminInternalMail = async (
c: Context<HonoCustomType>, toMail: string, subject: string, text: string
): Promise<boolean> => {