diff src/services/anilist.cc @ 365:f81bed4e04ac

*: megacommit that probably breaks things
author Paper <paper@paper.us.eu.org>
date Wed, 02 Oct 2024 23:06:43 -0400
parents 948955c3ba81
children
line wrap: on
line diff
--- a/src/services/anilist.cc	Tue Jul 16 21:15:59 2024 -0400
+++ b/src/services/anilist.cc	Wed Oct 02 23:06:43 2024 -0400
@@ -70,25 +70,15 @@
 
 /* FIXME: why is this here */
 
-static bool AccountIsValid() {
-	const auto& auth = session.config.auth.anilist;
-	return (auth.user_id && !auth.auth_token.empty());
-}
-
 static std::optional<nlohmann::json> SendJSONRequest(const nlohmann::json& data) {
-	if (!AccountIsValid()) {
-		session.SetStatusBar(Strings::Translate("AniList: Account isn't valid! (unauthorized?)"));
-		return std::nullopt;
-	}
-
-	const auto& auth = session.config.auth.anilist;
-
-	const std::vector<std::string> headers = {
-		"Authorization: Bearer " + auth.auth_token,
+	std::vector<std::string> headers = {
 		"Accept: application/json",
 		"Content-Type: application/json",
 	};
 
+	if (!session.config.auth.anilist.auth_token.empty())
+		headers.push_back("Authorization: Bearer " + session.config.auth.anilist.auth_token);
+
 	const std::string response = Strings::ToUtf8String(HTTP::Request("https://graphql.anilist.co", headers, data.dump(), HTTP::Type::Post));
 	if (response.empty()) {
 		session.SetStatusBar(Strings::Translate("AniList: JSON request returned an empty result!"));