mirror of
https://github.com/beilunyang/moemail.git
synced 2026-08-28 03:16:38 +08:00
feat: Email addresses are not case sensitive
This commit is contained in:
@@ -57,7 +57,7 @@ export async function POST(request: Request) {
|
|||||||
|
|
||||||
const address = `${name || nanoid(8)}@${domain}`
|
const address = `${name || nanoid(8)}@${domain}`
|
||||||
const existingEmail = await db.query.emails.findFirst({
|
const existingEmail = await db.query.emails.findFirst({
|
||||||
where: eq(emails.address, address)
|
where: eq(sql`LOWER(${emails.address})`, address.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|
||||||
if (existingEmail) {
|
if (existingEmail) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Env } from '../types'
|
import { Env } from '../types'
|
||||||
import { drizzle } from 'drizzle-orm/d1'
|
import { drizzle } from 'drizzle-orm/d1'
|
||||||
import { messages, emails, webhooks } from '../app/lib/schema'
|
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 PostalMime from 'postal-mime'
|
||||||
import { WEBHOOK_CONFIG } from '../app/config/webhook'
|
import { WEBHOOK_CONFIG } from '../app/config/webhook'
|
||||||
import { EmailMessage } from '../app/lib/webhook'
|
import { EmailMessage } from '../app/lib/webhook'
|
||||||
@@ -15,7 +15,7 @@ const handleEmail = async (message: ForwardableEmailMessage, env: Env) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const targetEmail = await db.query.emails.findFirst({
|
const targetEmail = await db.query.emails.findFirst({
|
||||||
where: eq(emails.address, message.to)
|
where: eq(sql`LOWER(${emails.address})`, message.to.toLowerCase())
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!targetEmail) {
|
if (!targetEmail) {
|
||||||
|
|||||||
Reference in New Issue
Block a user