mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-05 23:47:50 +08:00
feat: add adminContact && DEFAULT_SEND_BALANCE (#162)
This commit is contained in:
@@ -146,6 +146,7 @@ api.get('/open_api/settings', async (c) => {
|
||||
"prefix": c.env.PREFIX,
|
||||
"domains": getDomains(c),
|
||||
"needAuth": needAuth,
|
||||
"adminContact": c.env.ADMIN_CONTACT,
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
@@ -8,9 +8,12 @@ api.post('/api/requset_send_mail_access', async (c) => {
|
||||
return c.text("No address", 400)
|
||||
}
|
||||
try {
|
||||
const default_balance = c.env.DEFAULT_SEND_BALANCE || 0;
|
||||
const { success } = await c.env.DB.prepare(
|
||||
`INSERT INTO address_sender (address, balance, enabled) VALUES (?, 1, 1)`
|
||||
).bind(address).run();
|
||||
`INSERT INTO address_sender (address, balance, enabled) VALUES (?, ?, ?)`
|
||||
).bind(
|
||||
address, default_balance, default_balance > 0 ? 1 : 0
|
||||
).run();
|
||||
if (!success) {
|
||||
return c.text("Failed to request send mail access", 500)
|
||||
}
|
||||
|
||||
+3
-2
@@ -23,13 +23,14 @@ export const getPasswords = (c) => {
|
||||
// check if PASSWORDS is an array, if not use json.parse
|
||||
if (!Array.isArray(c.env.PASSWORDS)) {
|
||||
try {
|
||||
return JSON.parse(c.env.PASSWORDS);
|
||||
let res = JSON.parse(c.env.PASSWORDS);
|
||||
return res.filter((item) => item.length > 0);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse PASSWORDS", e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
return c.env.PASSWORDS;
|
||||
return c.env.PASSWORDS.filter((item) => item.length > 0);
|
||||
}
|
||||
|
||||
export const getAdminPasswords = (c) => {
|
||||
|
||||
Reference in New Issue
Block a user