xf
This commit is contained in:
@@ -5,6 +5,7 @@ from .utils import (get_latest_emails, get_latest_email_with_code,
|
|||||||
get_allowed_domains, get_allowed_domains_with_time,
|
get_allowed_domains, get_allowed_domains_with_time,
|
||||||
get_all_emails)
|
get_all_emails)
|
||||||
import redis
|
import redis
|
||||||
|
import json
|
||||||
|
|
||||||
def create_app():
|
def create_app():
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@@ -64,11 +65,22 @@ def create_app():
|
|||||||
app.logger.error(f"Error in list_emails_page: {str(e)}")
|
app.logger.error(f"Error in list_emails_page: {str(e)}")
|
||||||
return "获取邮件列表失败", 500
|
return "获取邮件列表失败", 500
|
||||||
|
|
||||||
@app.route('/web/email/<recipient>')
|
@app.route('/web/email/<message_id>')
|
||||||
def view_email_page(recipient):
|
def view_email_page(message_id):
|
||||||
try:
|
try:
|
||||||
email = get_latest_email_with_code(recipient)
|
# 直接从 Redis 获取邮件数据
|
||||||
if email:
|
email_key = f"email:{message_id}"
|
||||||
|
email_data = redis_client.hgetall(email_key)
|
||||||
|
if email_data:
|
||||||
|
# 转换字节数据为字符串
|
||||||
|
email = {k.decode(): v.decode() for k, v in email_data.items()}
|
||||||
|
# 解析 JSON 字符串字段
|
||||||
|
for field in ['recipients', 'attachments', 'headers', 'peer']:
|
||||||
|
if field in email:
|
||||||
|
try:
|
||||||
|
email[field] = json.loads(email[field])
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return render_template('email_detail.html', email=email)
|
return render_template('email_detail.html', email=email)
|
||||||
return "邮件不存在", 404
|
return "邮件不存在", 404
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<ul class="email-list">
|
<ul class="email-list">
|
||||||
{% for email in emails %}
|
{% for email in emails %}
|
||||||
<li class="email-item">
|
<li class="email-item">
|
||||||
<a href="{{ url_for('view_email_page', recipient=email.message_id) }}">
|
<a href="{{ url_for('view_email_page', message_id=email.message_id) }}">
|
||||||
<div class="email-subject">{{ email.subject }}</div>
|
<div class="email-subject">{{ email.subject }}</div>
|
||||||
<div class="email-meta">
|
<div class="email-meta">
|
||||||
发件人: {{ email.sender }} |
|
发件人: {{ email.sender }} |
|
||||||
|
|||||||
Reference in New Issue
Block a user