mirror of
https://github.com/simple-login/app.git
synced 2024-11-13 04:04:55 +08:00
parent
0ec4a3971c
commit
68cf54b2d9
1 changed files with 20 additions and 19 deletions
|
@ -31,7 +31,6 @@ It should contain the following info:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
|
||||||
import email
|
import email
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -1712,7 +1711,7 @@ def should_ignore(mail_from: str, rcpt_tos: List[str]) -> bool:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
async def handle(envelope: Envelope) -> str:
|
def handle(envelope: Envelope) -> str:
|
||||||
"""Return SMTP status"""
|
"""Return SMTP status"""
|
||||||
|
|
||||||
# sanitize mail_from, rcpt_tos
|
# sanitize mail_from, rcpt_tos
|
||||||
|
@ -1935,7 +1934,7 @@ async def handle(envelope: Envelope) -> str:
|
||||||
class MailHandler:
|
class MailHandler:
|
||||||
async def handle_DATA(self, server, session, envelope: Envelope):
|
async def handle_DATA(self, server, session, envelope: Envelope):
|
||||||
try:
|
try:
|
||||||
ret = await self._handle(envelope)
|
ret = self._handle(envelope)
|
||||||
return ret
|
return ret
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.e(
|
LOG.e(
|
||||||
|
@ -1946,7 +1945,7 @@ class MailHandler:
|
||||||
return status.E404
|
return status.E404
|
||||||
|
|
||||||
@newrelic.agent.background_task(application=newrelic_app)
|
@newrelic.agent.background_task(application=newrelic_app)
|
||||||
async def _handle(self, envelope: Envelope):
|
def _handle(self, envelope: Envelope):
|
||||||
start = time.time()
|
start = time.time()
|
||||||
|
|
||||||
# generate a different message_id to keep track of an email lifecycle
|
# generate a different message_id to keep track of an email lifecycle
|
||||||
|
@ -1959,7 +1958,9 @@ class MailHandler:
|
||||||
envelope.rcpt_tos,
|
envelope.rcpt_tos,
|
||||||
)
|
)
|
||||||
|
|
||||||
ret = await handle(envelope)
|
app = new_app()
|
||||||
|
with app.app_context():
|
||||||
|
ret = handle(envelope)
|
||||||
elapsed = time.time() - start
|
elapsed = time.time() - start
|
||||||
LOG.i(
|
LOG.i(
|
||||||
"Finish mail from %s, rctp tos %s, takes %s seconds <<===",
|
"Finish mail from %s, rctp tos %s, takes %s seconds <<===",
|
||||||
|
|
Loading…
Reference in a new issue