feat: add EMAIL_KV_BLACK_LIST (#394)

This commit is contained in:
Dream Hunter
2024-08-11 20:34:10 +08:00
committed by GitHub
parent c733d3bf4d
commit ac31042e69
8 changed files with 48 additions and 8 deletions
+3 -2
View File
@@ -5,11 +5,12 @@ import { sendMailToTelegram } from "../telegram_api";
import { Bindings, HonoCustomType } from "../types";
import { auto_reply } from "./auto_reply";
import { trigerWebhook } from "../mails_api/webhook_settings";
import { isBlocked } from "./black_list";
async function email(message: ForwardableEmailMessage, env: Bindings, ctx: ExecutionContext) {
if (env.BLACK_LIST && env.BLACK_LIST.split(",").some(word => message.from.includes(word))) {
message.setReject("Missing from address");
if (await isBlocked(message.from, env)) {
message.setReject("Reject from address");
console.log(`Reject message from ${message.from} to ${message.to}`);
return;
}