From 1363fb809436464de57b90113864ff50867a9dae Mon Sep 17 00:00:00 2001
From: Brahim Hadriche <brahim.hadriche@gmail.com>
Date: Tue, 28 Nov 2023 21:34:17 -0500
Subject: [PATCH 1/3] Fix error code for disabled popular endpoint

---
 src/invidious/routes/api/v1/feeds.cr | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/invidious/routes/api/v1/feeds.cr b/src/invidious/routes/api/v1/feeds.cr
index 41865f34b..0ee22ca64 100644
--- a/src/invidious/routes/api/v1/feeds.cr
+++ b/src/invidious/routes/api/v1/feeds.cr
@@ -30,8 +30,7 @@ module Invidious::Routes::API::V1::Feeds
     env.response.content_type = "application/json"
 
     if !CONFIG.popular_enabled
-      error_message = {"error" => "Administrator has disabled this endpoint."}.to_json
-      haltf env, 400, error_message
+      return error_json(403, "Administrator has disabled this endpoint.")
     end
 
     JSON.build do |json|

From c5eb10b21f742041ad3dad809a0f5aa6ce339c17 Mon Sep 17 00:00:00 2001
From: Brahim Hadriche <brahim.hadriche@gmail.com>
Date: Mon, 1 Apr 2024 10:02:49 -0400
Subject: [PATCH 2/3] Revert "Fix error code for disabled popular endpoint"

This reverts commit 1363fb809436464de57b90113864ff50867a9dae.
---
 src/invidious/routes/api/v1/feeds.cr | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/invidious/routes/api/v1/feeds.cr b/src/invidious/routes/api/v1/feeds.cr
index 0ee22ca64..41865f34b 100644
--- a/src/invidious/routes/api/v1/feeds.cr
+++ b/src/invidious/routes/api/v1/feeds.cr
@@ -30,7 +30,8 @@ module Invidious::Routes::API::V1::Feeds
     env.response.content_type = "application/json"
 
     if !CONFIG.popular_enabled
-      return error_json(403, "Administrator has disabled this endpoint.")
+      error_message = {"error" => "Administrator has disabled this endpoint."}.to_json
+      haltf env, 400, error_message
     end
 
     JSON.build do |json|

From b0c6bdf44c7fdff97d4fd408a7fede67f82e68a6 Mon Sep 17 00:00:00 2001
From: Brahim Hadriche <brahim.hadriche@gmail.com>
Date: Mon, 1 Apr 2024 10:03:29 -0400
Subject: [PATCH 3/3] use 403 code

---
 src/invidious/routes/api/v1/feeds.cr | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/invidious/routes/api/v1/feeds.cr b/src/invidious/routes/api/v1/feeds.cr
index 41865f34b..fea2993c6 100644
--- a/src/invidious/routes/api/v1/feeds.cr
+++ b/src/invidious/routes/api/v1/feeds.cr
@@ -31,7 +31,7 @@ module Invidious::Routes::API::V1::Feeds
 
     if !CONFIG.popular_enabled
       error_message = {"error" => "Administrator has disabled this endpoint."}.to_json
-      haltf env, 400, error_message
+      haltf env, 403, error_message
     end
 
     JSON.build do |json|