mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-05 23:47:50 +08:00
fix: name max 30 && /external/api/send_mail not return result (#222)
This commit is contained in:
@@ -68,12 +68,15 @@ onMounted(() => {
|
|||||||
<div v-if="openSettings.cfTurnstileSiteKey" class="center">
|
<div v-if="openSettings.cfTurnstileSiteKey" class="center">
|
||||||
<n-spin description="loading..." :show="turnstileLoading">
|
<n-spin description="loading..." :show="turnstileLoading">
|
||||||
<n-form-item-row>
|
<n-form-item-row>
|
||||||
<div id="cf-turnstile"></div>
|
<n-flex vertical>
|
||||||
<n-button text @click="checkCfTurnstile(true)">
|
<div id="cf-turnstile"></div>
|
||||||
{{ t('refresh') }}
|
<n-button text @click="checkCfTurnstile(true)">
|
||||||
</n-button>
|
{{ t('refresh') }}
|
||||||
|
</n-button>
|
||||||
|
</n-flex>
|
||||||
</n-form-item-row>
|
</n-form-item-row>
|
||||||
</n-spin>
|
</n-spin>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,12 @@ export const newAddress = async (c, name, domain, enablePrefix) => {
|
|||||||
if (name.length < 0) {
|
if (name.length < 0) {
|
||||||
return c.text("Name too short", 400)
|
return c.text("Name too short", 400)
|
||||||
}
|
}
|
||||||
if (name.length > 100) {
|
// create address
|
||||||
return c.text("Name too long (max 100)", 400)
|
if (enablePrefix) {
|
||||||
|
name = getStringValue(c.env.PREFIX) + name;
|
||||||
|
}
|
||||||
|
if (name.length >= 30) {
|
||||||
|
return c.text("Name too long (max 30)", 400)
|
||||||
}
|
}
|
||||||
// check domain, generate random domain
|
// check domain, generate random domain
|
||||||
const domains = getDomains(c);
|
const domains = getDomains(c);
|
||||||
@@ -18,11 +22,7 @@ export const newAddress = async (c, name, domain, enablePrefix) => {
|
|||||||
domain = domains[Math.floor(Math.random() * domains.length)];
|
domain = domains[Math.floor(Math.random() * domains.length)];
|
||||||
}
|
}
|
||||||
// create address
|
// create address
|
||||||
if (enablePrefix) {
|
name = name + "@" + domain;
|
||||||
name = getStringValue(c.env.PREFIX) + name + "@" + domain;
|
|
||||||
} else {
|
|
||||||
name = name + "@" + domain;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
const { success } = await c.env.DB.prepare(
|
const { success } = await c.env.DB.prepare(
|
||||||
`INSERT INTO address(name) VALUES(?)`
|
`INSERT INTO address(name) VALUES(?)`
|
||||||
|
|||||||
@@ -161,7 +161,8 @@ api.post('/external/api/send_mail', async (c) => {
|
|||||||
return c.text("No address", 400)
|
return c.text("No address", 400)
|
||||||
}
|
}
|
||||||
const reqJson = await c.req.json();
|
const reqJson = await c.req.json();
|
||||||
return await sendMail(c, address, reqJson);
|
await sendMail(c, address, reqJson);
|
||||||
|
return c.json({ status: "ok" })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to send mail", e);
|
console.error("Failed to send mail", e);
|
||||||
return c.text(`Failed to send mail ${e.message}`, 400)
|
return c.text(`Failed to send mail ${e.message}`, 400)
|
||||||
|
|||||||
Reference in New Issue
Block a user