From 9a94241730fcfdc9ee315730c213e0d8add114c7 Mon Sep 17 00:00:00 2001 From: vulonkaaz <7442677+vulonkaaz@users.noreply.github.com> Date: Wed, 28 May 2025 21:09:29 +0200 Subject: rate limiting (frontend) --- views/partials/canvas.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/views/partials/canvas.html b/views/partials/canvas.html index a336844..d51efc1 100644 --- a/views/partials/canvas.html +++ b/views/partials/canvas.html @@ -95,12 +95,17 @@ "Content-type": "application/json; charset=UTF-8" } }) - .then((response) => response.json()) - .then((json) => { - if (json.status == "ok") { - location.reload(); - } - }); + .then((response) => { + if (response.status === 429) { + alert("Rate limited! Only 5 messages every 10 minutes, sorry for the inconvenience"); + } + return response.json(); + }) + .then((json) => { + if (json.status == "ok") { + location.reload(); + } + }); } const sendbtn = document.getElementById('sendbtn'); sendbtn.addEventListener("click", sendPic); -- cgit v1.2.3