fix: restore web chat delete endpoint
This commit is contained in:
+2
-2
@@ -293,10 +293,10 @@ async function deleteChatMessage(item: ChatItem, ban = false) {
|
||||
if (!await askConfirm(action, `确认${action}这条消息?`, { confirmText: action, danger: true })) return;
|
||||
item._deleting = true;
|
||||
try {
|
||||
await fetchJson(`/api/chat/${item.id}/delete`, {
|
||||
await fetchJson(`/api/messages/${item.id}/delete`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ ban })
|
||||
body: JSON.stringify({ ban_user: ban })
|
||||
});
|
||||
Object.assign(item, { deleted: true, manually_deleted: true });
|
||||
await loadStats();
|
||||
|
||||
+2
-1
@@ -522,6 +522,7 @@ async def api_send(request: Request):
|
||||
return JSONResponse({"ok": True, "msg_id": msg.message_id})
|
||||
|
||||
|
||||
@app.post("/api/chat/{message_id}/delete")
|
||||
@app.post("/api/messages/{message_id}/delete")
|
||||
async def api_delete_message(message_id: int, request: Request):
|
||||
"""手动删除聊天记录:先删 Telegram 消息,再把数据库记录标记为已删除。"""
|
||||
@@ -531,7 +532,7 @@ async def api_delete_message(message_id: int, request: Request):
|
||||
from telegram.request import HTTPXRequest
|
||||
|
||||
data = await request.json() if request.headers.get("content-type", "").startswith("application/json") else {}
|
||||
ban_user = bool(data.get("ban_user"))
|
||||
ban_user = bool(data.get("ban_user") or data.get("ban"))
|
||||
|
||||
rec = await Message.get_or_none(id=message_id)
|
||||
if not rec:
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="icon" type="image/svg+xml" href="/static/icon.svg" />
|
||||
<title>TG Spam Guard</title>
|
||||
<script type="module" crossorigin src="/static/assets/index-BkB3pxMb.js"></script>
|
||||
<script type="module" crossorigin src="/static/assets/index-BLyluaUp.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/static/assets/index-DEuQ3oiJ.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user