feature: 基于子域名转发到不同的邮箱中去 (#645) (#647)

This commit is contained in:
Zyx-A
2025-04-30 10:41:09 +08:00
committed by GitHub
parent 101a561894
commit 07833d5ca9
5 changed files with 52 additions and 2 deletions
+17 -1
View File
@@ -1,6 +1,6 @@
import { Context } from "hono";
import { createMimeMessage } from "mimetext";
import { HonoCustomType, UserRole, AnotherWorker } from "./types";
import { HonoCustomType, UserRole, SubdomainForwardAddressList, AnotherWorker } from "./types";
export const getJsonObjectValue = <T = any>(
value: string | any
@@ -165,6 +165,22 @@ export const getUserRoles = (c: Context<HonoCustomType>): UserRole[] => {
return c.env.USER_ROLES;
}
export const getSubdomainForwardAddressList = (c: Context<HonoCustomType>): SubdomainForwardAddressList[] => {
if (!c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST) {
return [];
}
// check if SUBDOMAIN_FORWARD_ADDRESS_LIST is an array, if not use json.parse
if (!Array.isArray(c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST)) {
try {
return JSON.parse(c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST);
} catch (e) {
console.error("Failed to parse SUBDOMAIN_FORWARD_ADDRESS_LIST", e);
return [];
}
}
return c.env.SUBDOMAIN_FORWARD_ADDRESS_LIST;
}
export const getAnotherWorkerList = (c: Context<HonoCustomType>): AnotherWorker[] => {
if (!c.env.ANOTHER_WORKER_LIST) {
return [];