mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-05-22 00:29:53 +08:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { Context } from "hono";
|
|
import { HonoCustomType } from "../types";
|
|
import { CONSTANTS } from "../constants";
|
|
|
|
export class TelegramSettings {
|
|
enableAllowList: boolean;
|
|
allowList: string[];
|
|
miniAppUrl: string;
|
|
enableGlobalMailPush: boolean;
|
|
globalMailPushList: string[];
|
|
|
|
constructor(
|
|
enableAllowList: boolean, allowList: string[], miniAppUrl: string,
|
|
enableGlobalMailPush: boolean, globalMailPushList: string[]
|
|
) {
|
|
this.enableAllowList = enableAllowList;
|
|
this.allowList = allowList;
|
|
this.miniAppUrl = miniAppUrl;
|
|
this.enableGlobalMailPush = enableGlobalMailPush;
|
|
this.globalMailPushList = globalMailPushList;
|
|
}
|
|
}
|
|
|
|
async function getTelegramSettings(c: Context<HonoCustomType>): Promise<Response> {
|
|
const settings = await c.env.KV.get<TelegramSettings>(CONSTANTS.TG_KV_SETTINGS_KEY, "json");
|
|
return c.json(settings || new TelegramSettings(false, [], "", false, []));
|
|
}
|
|
|
|
|
|
async function saveTelegramSettings(c: Context<HonoCustomType>): Promise<Response> {
|
|
const settings = await c.req.json<TelegramSettings>();
|
|
await c.env.KV.put(CONSTANTS.TG_KV_SETTINGS_KEY, JSON.stringify(settings));
|
|
return c.json({ success: true })
|
|
}
|
|
|
|
export default {
|
|
getTelegramSettings,
|
|
saveTelegramSettings,
|
|
}
|