feat: add adminContact && DEFAULT_SEND_BALANCE (#162)

This commit is contained in:
Dream Hunter
2024-04-26 00:21:43 +08:00
committed by GitHub
parent b058a1bd12
commit f624fe5b58
17 changed files with 175 additions and 110 deletions

View File

@@ -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)
}