feat: Email addresses are not case sensitive

This commit is contained in:
beilunyang
2025-01-17 21:58:27 +08:00
parent 5df270a471
commit 1bc0369b83
2 changed files with 3 additions and 3 deletions

View File

@@ -57,7 +57,7 @@ export async function POST(request: Request) {
const address = `${name || nanoid(8)}@${domain}`
const existingEmail = await db.query.emails.findFirst({
where: eq(emails.address, address)
where: eq(sql`LOWER(${emails.address})`, address.toLowerCase())
})
if (existingEmail) {

View File

@@ -1,7 +1,7 @@
import { Env } from '../types'
import { drizzle } from 'drizzle-orm/d1'
import { messages, emails, webhooks } from '../app/lib/schema'
import { eq } from 'drizzle-orm'
import { eq, sql } from 'drizzle-orm'
import PostalMime from 'postal-mime'
import { WEBHOOK_CONFIG } from '../app/config/webhook'
import { EmailMessage } from '../app/lib/webhook'
@@ -15,7 +15,7 @@ const handleEmail = async (message: ForwardableEmailMessage, env: Env) => {
try {
const targetEmail = await db.query.emails.findFirst({
where: eq(emails.address, message.to)
where: eq(sql`LOWER(${emails.address})`, message.to.toLowerCase())
})
if (!targetEmail) {