mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
Fix: send custom webhook JSON in UTF-8
CUSTOM webhooks were receiving JSON-escaped Unicode (e.g. \\u5229...) because requests' json= payload uses ensure_ascii=True by default. Change send_to_custom() to serialize payload with json.dumps(..., ensure_ascii=False), send bytes as UTF-8, and set Content-Type to application/json; charset=utf-8. Impact: receivers see proper Chinese characters in the payload fields.
This commit is contained in:
@@ -15,6 +15,7 @@ A股自选股智能分析系统 - 通知层
|
||||
"""
|
||||
|
||||
import logging
|
||||
import json
|
||||
import smtplib
|
||||
import re
|
||||
from datetime import datetime
|
||||
@@ -1678,10 +1679,13 @@ class NotificationService:
|
||||
'User-Agent': 'StockAnalysis/1.0'
|
||||
}
|
||||
|
||||
body = json.dumps(payload, ensure_ascii=False).encode('utf-8')
|
||||
headers_with_charset = dict(headers)
|
||||
headers_with_charset['Content-Type'] = 'application/json; charset=utf-8'
|
||||
response = requests.post(
|
||||
url,
|
||||
json=payload,
|
||||
headers=headers,
|
||||
data=body,
|
||||
headers=headers_with_charset,
|
||||
timeout=30
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user