From 0b66bae39759a5553d8ce46131dca3026325097b Mon Sep 17 00:00:00 2001
From: Roman Sergienko <romasergienko@outlook.com>
Date: Fri, 04 Dec 2026 11:19:03 +0000
Subject: [PATCH] Fix RP action upload response handling

---
 web/templates/rp.html |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/web/templates/rp.html b/web/templates/rp.html
index 4a53752..e189ea3 100644
--- a/web/templates/rp.html
+++ b/web/templates/rp.html
@@ -61,7 +61,13 @@
             method: 'POST',
             body: formData
         });
-        const result = await response.json();
+        const body = await response.text();
+        let result;
+        try {
+            result = JSON.parse(body);
+        } catch (err) {
+            throw new Error(`Сервер вернул не JSON (HTTP ${response.status}): ${body.slice(0, 240)}`);
+        }
         
         msgEl.classList.remove('hidden');
         if (result.ok) {
@@ -93,7 +99,13 @@
                 headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                 body: new URLSearchParams({action_id: actionId, chat_id: chatId})
             });
-            const result = await response.json();
+            const body = await response.text();
+            let result;
+            try {
+                result = JSON.parse(body);
+            } catch (err) {
+                throw new Error(`Сервер вернул не JSON (HTTP ${response.status}): ${body.slice(0, 240)}`);
+            }
             
             if (result.ok) {
                 btn.closest('.flex').remove();

--
Gitblit v1.9.3