添加sentry、新增公告筛选功能

This commit is contained in:
fanbook-wangdage
2026-01-08 23:34:42 +08:00
parent d67e42b067
commit a4d95e4f90
4 changed files with 26 additions and 6 deletions

View File

@@ -1,11 +1,19 @@
from app.extensions import client
from app.extensions import client, logger
from app.config import Config
def get_announcements():
def get_announcements(request_data: list):
if Config.ISTEST_MODE:
return []
# 记录请求体到日志请求体中是用户已关闭的公告ID列表
logger.debug("Request body: %s", request_data)
announcements = list(client.ht_server.announcement.find({}))
result = []
for a in announcements:
# 拷贝并移除 _id 字段,避免 ObjectId 无法序列化
a = dict(a)
a.pop('_id', None)
return announcements
# 如果请求体中包含该公告ID说明用户已关闭该公告不返回该公告
if a.get('Id') not in request_data:
result.append(a)
return result