From 40d1e4fb89e332ff34c0996f56eee012ec0ddb15 Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Fri, 04 Dec 2026 11:29:08 +0000
Subject: [PATCH] Show and manage disabled RP actions; improve mobile layout
---
web/views.py | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/web/views.py b/web/views.py
index 7b5ec8b..0f55ae7 100644
--- a/web/views.py
+++ b/web/views.py
@@ -656,7 +656,7 @@
file_path = gif_dir / file_name
# Сохраняем файл
- content = await file.read()
+ content = file.file.read()
with open(file_path, "wb") as f:
f.write(content)
@@ -695,3 +695,25 @@
await db.delete_rp_action(action_id)
await db.add_log(chat_id, user["user_id"], 0, "rp_delete", action["trigger"], now_ts())
return web.json_response({"ok": True})
+
+
+async def api_rp_toggle(request) -> web.Response:
+ user = await _user(request)
+ data = await request.post()
+ try:
+ action_id = int(data["action_id"])
+ chat_id = int(data["chat_id"])
+ enabled = data.get("enabled") == "1"
+ except (KeyError, ValueError):
+ return web.json_response({"ok": False, "msg": "Некорректные данные."}, status=400)
+
+ if chat_id not in await _allowed_ids(user["user_id"]):
+ return web.json_response({"ok": False, "msg": "Нет доступа."}, status=403)
+
+ action = await db.get_rp_action(action_id)
+ if not action or action["chat_id"] != chat_id:
+ return web.json_response({"ok": False, "msg": "Действие не найдено."}, status=404)
+
+ await db.set_rp_action_enabled(action_id, enabled)
+ await db.add_log(chat_id, user["user_id"], 0, "rp_enable" if enabled else "rp_disable", action["trigger"], now_ts())
+ return web.json_response({"ok": True})
--
Gitblit v1.9.3