mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-05-12 02:20:12 +08:00
feat: telegram bot TelegramSettings && webhook (#244)
* feat: telegram bot TelegramSettings * feat: webhook
This commit is contained in:
34
worker/src/commom_api.ts
Normal file
34
worker/src/commom_api.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { Hono } from 'hono'
|
||||
|
||||
// @ts-ignore
|
||||
import { getDomains, getPasswords, getBooleanValue } from './utils';
|
||||
import { CONSTANTS } from './constants';
|
||||
import { Bindings } from './types';
|
||||
|
||||
const api = new Hono<{ Bindings: Bindings }>
|
||||
|
||||
api.get('/open_api/settings', async (c) => {
|
||||
// check header x-custom-auth
|
||||
let needAuth = false;
|
||||
const passwords = getPasswords(c);
|
||||
if (passwords && passwords.length > 0) {
|
||||
const auth = c.req.raw.headers.get("x-custom-auth");
|
||||
needAuth = !passwords.includes(auth);
|
||||
}
|
||||
return c.json({
|
||||
"prefix": c.env.PREFIX,
|
||||
"domains": getDomains(c),
|
||||
"needAuth": needAuth,
|
||||
"adminContact": c.env.ADMIN_CONTACT,
|
||||
"enableUserCreateEmail": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
|
||||
"enableUserDeleteEmail": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
|
||||
"enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
|
||||
"enableIndexAbout": getBooleanValue(c.env.ENABLE_INDEX_ABOUT),
|
||||
"copyright": c.env.COPYRIGHT,
|
||||
"cfTurnstileSiteKey": c.env.CF_TURNSTILE_SITE_KEY,
|
||||
"enableWebhook": getBooleanValue(c.env.ENABLE_WEBHOOK),
|
||||
"version": CONSTANTS.VERSION,
|
||||
});
|
||||
})
|
||||
|
||||
export { api }
|
||||
Reference in New Issue
Block a user