From 669e1e3b18925ce9f4bc91bb9d03478bcd50b166 Mon Sep 17 00:00:00 2001 From: Kees van Kempen Date: Tue, 5 Mar 2024 10:45:16 +0100 Subject: [PATCH] fix(queues): now really fix the request notifications Instead of checking for success, now the correct HTTP response code is sent by the request API. My previous fix broke the other responses, oops. Closes #82 Relates #44 The refresh as introduced in my fix for #82 (!89) is reverted, as this was already done on successful requests. --- marietje/queues/api/v1/views.py | 2 +- marietje/queues/templates/queues/queue.html | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/marietje/queues/api/v1/views.py b/marietje/queues/api/v1/views.py index 446cfd2..5a33124 100644 --- a/marietje/queues/api/v1/views.py +++ b/marietje/queues/api/v1/views.py @@ -163,7 +163,7 @@ class QueueRequestAPIView(CreateAPIView): try: playlist_song = queue.request(song, request.user) except RequestException as e: - return Response(data={"success": False, "errorMessage": str(e)}) + return Response(status=403, data={"success": False, "errorMessage": str(e)}) request_counter.labels(queue=queue.name).inc() return Response(status=200, data=self.serializer_class(playlist_song).data) diff --git a/marietje/queues/templates/queues/queue.html b/marietje/queues/templates/queues/queue.html index c280c04..e68b34b 100644 --- a/marietje/queues/templates/queues/queue.html +++ b/marietje/queues/templates/queues/queue.html @@ -594,8 +594,7 @@ "Content-Type": 'application/json', }, }).then(response => { - // TODO: Communicate failure through HTTP error codes (403) instead of checking response.success. - if (response.status === 200 && response.success) { + if (response.status === 200) { return response.json(); } else { throw response; @@ -612,7 +611,6 @@ tata.error('', "An unknown exception occurred.") } }); - queue_vue.refresh(); }, report_song(song_id) {